Skip to content

Commit

Permalink
Use content length to set a mark before attempting the reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndiritu committed Dec 9, 2024
1 parent a1ecc42 commit 597e554
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,15 @@ public long contentLength() throws IOException {

@Override
public void writeTo(@Nonnull BufferedSink sink) throws IOException {
// stored in variable before writing to the sink due to
// available()'s definition
long contentLength = contentLength();
sink.writeAll(Okio.source(requestInfo.content));
if (!isOneShot()) {
try {
if (contentLength > 0) {
requestInfo.content.mark((int) contentLength);
}
requestInfo.content.reset();
} catch (Exception ex) {
spanForAttributes.recordException(ex);
Expand Down

0 comments on commit 597e554

Please sign in to comment.