Bugfix/0 byte download from s3 using http #2479
Merged
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.
Issue #, if available:
This PR fixes an issue similar to #738, but which only appears when using HTTP endpoints. When downloading an empty (0-byte) file from S3 using Transfer API and using HTTP (not HTTPS) endpoints, the download fails with CurlCode 56 (connection reset by peer.) Issue has been present since 1.7.x release series.
The 0-byte file size causes
TransferManager::DoSinglePartDownload
to callrequest.SetRange(FormatRangeSpecifier, 0, 0+0-1))
, which results in a malformedrange:
header due to integer underflow. Protection had been added for this underflow issue to some codepaths, but not to this one.Interestingly, in HTTPS mode, the S3 REST API seems to accept this malformed
range
header without complaint. I have no explanation for the behavior difference between HTTP and HTTPS endpoints, but maybe it has something to do with the way sigv4 signing is forced on with HTTP endpoints.Description of changes:
TransferManager
(TransferTests
) such that they all run in both HTTP and HTTPS mode.The existing
EmptyFileTest
is sufficient to regression-test this issue when it is run against the HTTP endpoint. I have verified that the unit test as currently written in this PR will repro the issue reliably and that my bugfix causes the tests to pass.Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.