fix(cache): set content length for put artifact #9183
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.
Description
Fixes #9177
In #8081 we changed from setting the body of our
PUT
requests from a vec of bytes to a stream of bytes.This results in the underlying
hyper
request having a body withKind::Wrapped
instead ofKind::Once
. This results in the body no longer having an exact length. With the body no longer having an exact length,hyper
would no longer setContent-Length
for us source.This PR explicitly sets the content length header. It would be nice if we could set the length on the body itself, but
hyper
doesn't allow for this flexibility. (We cannot simply implement a size hint onUploadProgress
, but the size hint should return the size of the stream, not the number of bytes in the stream)Testing Instructions
Added an assertion on the mock
PUT /artifacts
endpoint to make sure thatContent-Length
gets set.