Skip to content
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

Deactivate chunked body in S3 #911

Merged
merged 4 commits into from
Jan 13, 2021
Merged

Conversation

jderusse
Copy link
Member

Fixes #874

docs/clients/s3.md Outdated Show resolved Hide resolved
Comment on lines +98 to +101
if ($contentLength < self::CHUNK_SIZE || !$this->sendChunkedBody) {
if ($body instanceof ReadOnceResultStream) {
$request->setBody(RewindableStream::create($body));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the body is not an instance of ReadOnceResultStream?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$body is initialized from $body = $request->getBody().
If it's not an instance of ReadOnceResultStream, then we are good, we can rewind the stream.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fail to understand why though.. Before, we always converted to a StringStream if the body was small, but now we dont anymore. Was it a misstake before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe the conversation were not needed.

If I remember well, when I implemented the conversion to string, the ReadOnceResultStream did not exists and stream have to be converted into string at some point.

Now, thanks to the RewindableStream, the signature is able to works with all cases, but I forgot to revert upgrade this statement.

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if Im extra slow on this PR.

src/Service/S3/src/Signer/SignerV4ForS3.php Outdated Show resolved Hide resolved
Comment on lines +98 to +101
if ($contentLength < self::CHUNK_SIZE || !$this->sendChunkedBody) {
if ($body instanceof ReadOnceResultStream) {
$request->setBody(RewindableStream::create($body));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fail to understand why though.. Before, we always converted to a StringStream if the body was small, but now we dont anymore. Was it a misstake before?

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you see why the tests are failing?

@jderusse
Copy link
Member Author

last test fails because of doctrine/annotations#398

@jderusse jderusse merged commit ae07209 into async-aws:master Jan 13, 2021
@jderusse jderusse deleted the chunk-body branch January 13, 2021 07:56
@jderusse
Copy link
Member Author

Thank you for the review

@Nyholm
Copy link
Member

Nyholm commented Jan 13, 2021

Awesome. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[S3] Disable transferring payload in multiple chunks
2 participants