Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Status
Ready for review
Description of Changes
Fixes #3907.
This adds a range request test, and also makes it so the two routes that we need to support range requests include the
Accept-Ranges: bytes
header. The routes are:/sources/<source_uuid>/submissions/<submission_uuid>/download
/sources/<source_uuid>/replies/<reply_uuid>/download
Miraculously, implementing range requests themselves doesn't seem to be necessary because ... the test passes. It's already built-in to the version of Flask we're using, apparently.
And just for some background, here's the download submission route:
This responds with the file in
utils.serve_file_with_etag
. Here's that function:All the API is doing is using Flask's
send_file
function to load the encrypted file from disk and send it to the http client. There's no compression or anything else happening here, so range support should be easy.Testing
You can confirm it works by running the test and seeing it pass:
But I didn't quite believe it, so I manually tested it too like this:
make dev
To test using curl, first authenticate to the API, of course changing
one_time_code
:The response will be something like this:
Set the token for subsequent requests, changing the token to whatever you got:
Get the download URL for the last source's only submission (this uses
jq
so you might need to install it):Download it:
Now download just first 100 bytes:
Now grab the first 100 bytes from the full file:
And compare: