-
Notifications
You must be signed in to change notification settings - Fork 56
download_file: use GET for pre-signed S3 URIs #940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -734,8 +734,13 @@ def handle_content(request, context): | |
| assert search | ||
| from_bytes = int(search.group(1)) | ||
| to_bytes = int(search.group(2)) | ||
| assert from_bytes < to_bytes | ||
| return TIFF_CONTENT[from_bytes : to_bytes + 1] | ||
| assert from_bytes <= to_bytes | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change isn't directly related to this PR, except that these tests fail because the previous assert is too strict. |
||
| sliced_content = TIFF_CONTENT[from_bytes : to_bytes + 1] | ||
| context.status_code = 206 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless I'm misunderstanding something, the mock didn't respond with the right headers/status code for range requests earlier. |
||
| context.headers["Accept-Ranges"] = "bytes" | ||
| context.headers["Content-Range"] = f"bytes {from_bytes}-{to_bytes}/{len(TIFF_CONTENT)}" | ||
| context.headers["Content-Length"] = str(len(sliced_content)) | ||
| return sliced_content | ||
|
|
||
| requests_mock.get( | ||
| API_URL + "/jobs/jj1/results", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this doing a GET with 0-range headers is a good idea: this will only work if the server supports
range. If the server doesn't then the user will download the same, possibly large, payload twice (once for this head-emulation and once for doing the actual download a couple of lines lower in_download_all_at_once