Skip to content

Commit

Permalink
Merge pull request #411 from asfadmin/LTT-WIP
Browse files Browse the repository at this point in the history
Add timing for head check, FFW rain-api-core
  • Loading branch information
mckadesorensen authored Oct 11, 2021
2 parents 8d88f6d + 516e9db commit 39be703
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions lambda/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,13 @@ def try_download_from_bucket(bucket, filename, user_profile, headers: dict):
try:
# Make sure this file exists, don't ACTUALLY download
range_header = get_range_header_val()
if not range_header:
if not os.getenv("SUPPRESS_HEAD"):
head_check = client.head_object(Bucket=bucket, Key=filename)
redirheaders = {}
else:
if not os.getenv("SUPPRESS_HEAD"):
log.info(f"Range Header was {range_header}")
head_check = client.head_object(Bucket=bucket, Key=filename, Range=range_header)
redirheaders = {'Range': range_header}

if not os.getenv("SUPPRESS_HEAD"):
timer = time.time()
head_check = client.head_object(Bucket=bucket, Key=filename, Range=(range_header or ""))
log.info(return_timing_object(service="s3", endpoint="client.head_object()", duration=duration(timer)))

redirheaders = {'Range': range_header} if range_header else {}

expires_in = 3600 - offset
redirheaders['Cache-Control'] = 'private, max-age={0}'.format(expires_in - 60)
Expand Down
2 changes: 1 addition & 1 deletion rain-api-core

0 comments on commit 39be703

Please sign in to comment.