-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Use native Okio copy for retrying. #1224
Conversation
One way to work around this behavior would be to do a single- Buffer buffer = new Buffer();
thing.copyTo(buffer);
sink.write(buffer, buffer.size()); |
I'd still like to revert Okio's behavior. |
... but overall, I want Okio users to not have to think about where the buffer bytes are being stranded. Whatever we do should focus on that. |
We should do that ASAP then. |
76d1598
to
595d369
Compare
LGTY now that we're Okio 1.2.0-ing all up in this piece? |
// Clone the content; otherwise we won't have data to retry. | ||
Buffer buffer = content.clone(); | ||
socketOut.write(buffer, buffer.size()); | ||
BufferedSink bufferedOut = Okio.buffer(socketOut); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the BufferedSource here helps?
Buffer buffer = new Buffer();
content.copyTo(buffer, 0, content.size());
socketOut.write(buffer, buffer.size());
I don't really get what the motivation is here. Is |
I asked you that very same question a few weeks ago but I think our conversation got derailed. |
Cool. As it stands now, I don't think this changes behavior. LGTM. |
Use native Okio copy for retrying.
For your consideration and review, because this has a slight behavioral problem...
This method is called from two places in two different ways:
SpdyTransport.writeRequestBody
calls it with an instance ofSpdyDataSink
. This class is aSink
implementation which adds framing around a SPDYFrameWriter
who ultimately delegates to aBufferedSink
around theSocket
.HttpConnection.writeRequestBody
on the other hand passes aBufferedSink
which is directly wrapped around theSocket
.The distinction of the former being a
Sink
and the latter being aBufferedSink
means thatOkio.buffer
is going to behave differently. When we ultimately call.emit()
to ensure we're not leaking segments, one writes directly to aSocket
whereas the other hands off to anotherBuffer
and lets emission to the socket happen at the discretion of that sink.So, are we fine with that behavior? Do we revert Okio's behavior?