Skip to content

Flip NettyResponse's BodyPart ByteBuffer #1213

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

Merged
merged 1 commit into from
Jul 17, 2016

Conversation

marenzo
Copy link
Contributor

@marenzo marenzo commented Jul 17, 2016

Related to #1212

@@ -179,6 +179,7 @@ public ByteBuffer getResponseBodyAsByteBuffer() {
for (HttpResponseBodyPart part : bodyParts)
target.put(part.getBodyPartBytes());

target.rewind();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not flip?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does it matter? I don't mind to change to flip, but it's doesn't do anything special in this context - it's updates the state of limit to be the same as already defined (which is the buffer length), while rewind just sets back to the index to the beginning.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, flip is the idiomatic way for switching from write to read and vice versa, which is exactly what we need here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@slandelle slandelle added this to the 2.0.10 milestone Jul 17, 2016
@slandelle slandelle merged commit c3bb2bd into AsyncHttpClient:master Jul 17, 2016
@slandelle slandelle changed the title Rewinding NettyResponse's BodyPart ByteBuffer Flip NettyResponse's BodyPart ByteBuffer Jul 17, 2016
@slandelle
Copy link
Contributor

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants