Skip to content

fix(blocking): return response when server responds before the body is sent - #3132

Merged
seanmonstar merged 4 commits into
seanmonstar:masterfrom
felstead:fix/blocking-client-early-close
Nov 16, 2026
Merged

seanmonstar merged 4 commits into
seanmonstar:masterfrom
felstead:fix/blocking-client-early-close

Conversation

@felstead

Copy link
Copy Markdown
Contributor

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in #3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in send_future fails. That failure is now reported to execute_request (as BodySendError::RequestFinished) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error. Errors from the caller's Read still return immediately as before.

This could be achieved by simply returning Ok(()) in async fn send_future(sender: Sender) in body.rs in lieu of returning BodySendError::RequestFinished - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new pub(crate) enum BodySendError type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit. Your call, I prefer the more explicit code, but I could make an argument either way.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (is_request()) instead of "send failed because receiver is gone" (is_body()). This makes the error consistent on both sides of the race - previously, depending on which thread won, it could be either of the two different errors.

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed Read still surfaces as a body error. I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131

Disclosure: This PR and its associated code were LLM assisted, I've reviewed all code and have written/rewritten the human portions myself (including this PR message) per the checkbox/blog-post below, but I figured I'd still call it out explicitly.

felstead and others added 2 commits November 9, 2026 16:17
…s sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes seanmonstar#3131
@felstead

Copy link
Copy Markdown
Contributor Author

Hey @seanmonstar - I see a bunch of failed tests here, I'm like 95% sure they're unrelated to my changes, but let me know if you'd like me to investigate them more. I don't think I have permissions to re-run tasks though.

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The blocking tests cover an early response from a sized reader and a read failure, but send_future also handles an unsized Body::new reader. Could the early-response regression run with an unsized body as well? It uses a different transfer framing path, and this change should return the server response when Hyper stops accepting that body too.

@felstead

felstead commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

The blocking tests cover an early response from a sized reader and a read failure, but send_future also handles an unsized Body::new reader. Could the early-response regression run with an unsized body as well? It uses a different transfer framing path, and this change should return the server response when Hyper stops accepting that body too.

Oh yeah, nice catch. I think the fix covers both cases, but let me move out the test helpers for the GatedReader to shared code and I will create a test scenario for the unsized version as well.

(edited)
Okay, both those scenarios are tested explicitly - they both converge at the same point at the failing channel send in send_future so this second test with chunked encoding is largely defensive, but definitely doesn't hurt as a future regression test.

@agammann

Copy link
Copy Markdown

I rechecked the current diff. The early-response regression now runs with both Body::sized and unsized Body::new, and the unsized case asserts chunked transfer framing. That covers the path I asked about. I reviewed the diff; I did not run tests locally. AI-assisted review.

Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Original source message:

fix(blocking): return response when server responds before the body is sent

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: def89130b8d38d2b4dc7410e2e89b8a5cf3290bb.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
fix(blocking): return response when server responds before the body is sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar/reqwest#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: 6fd412fccfca097d5a6a4aff6227d9fbcd41398a
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Original source message:

Modify "early response" tests to be able to test both a sized request and a chunked request.

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: d9e0523b0ad0e55f03e751ab057fd4c899057217.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
Modify "early response" tests to be able to test both a sized request and a chunked request.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: e91333b28aec23a8f13101f31f7db78271eba848
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Original source message:

fix(blocking): return response when server responds before the body is sent

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: def89130b8d38d2b4dc7410e2e89b8a5cf3290bb.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
fix(blocking): return response when server responds before the body is sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar/reqwest#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: 6fd412fccfca097d5a6a4aff6227d9fbcd41398a
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Original source message:

Modify "early response" tests to be able to test both a sized request and a chunked request.

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: d9e0523b0ad0e55f03e751ab057fd4c899057217.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
Modify "early response" tests to be able to test both a sized request and a chunked request.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: e91333b28aec23a8f13101f31f7db78271eba848
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: 6fd412fccfca097d5a6a4aff6227d9fbcd41398a
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

fix(blocking): return response when server responds before the body is sent

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: def89130b8d38d2b4dc7410e2e89b8a5cf3290bb.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
fix(blocking): return response when server responds before the body is sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar/reqwest#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: e91333b28aec23a8f13101f31f7db78271eba848
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

Modify "early response" tests to be able to test both a sized request and a chunked request.

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: d9e0523b0ad0e55f03e751ab057fd4c899057217.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
Modify "early response" tests to be able to test both a sized request and a chunked request.
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: 6fd412fccfca097d5a6a4aff6227d9fbcd41398a
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

fix(blocking): return response when server responds before the body is sent

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: def89130b8d38d2b4dc7410e2e89b8a5cf3290bb.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
fix(blocking): return response when server responds before the body is sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar/reqwest#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: e91333b28aec23a8f13101f31f7db78271eba848
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

Modify "early response" tests to be able to test both a sized request and a chunked request.

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: d9e0523b0ad0e55f03e751ab057fd4c899057217.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
Modify "early response" tests to be able to test both a sized request and a chunked request.
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: 6fd412fccfca097d5a6a4aff6227d9fbcd41398a
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

fix(blocking): return response when server responds before the body is sent

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: def89130b8d38d2b4dc7410e2e89b8a5cf3290bb.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
fix(blocking): return response when server responds before the body is sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar/reqwest#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: e91333b28aec23a8f13101f31f7db78271eba848
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

Modify "early response" tests to be able to test both a sized request and a chunked request.

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: d9e0523b0ad0e55f03e751ab057fd4c899057217.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
Modify "early response" tests to be able to test both a sized request and a chunked request.
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: 6fd412fccfca097d5a6a4aff6227d9fbcd41398a
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

fix(blocking): return response when server responds before the body is sent

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: def89130b8d38d2b4dc7410e2e89b8a5cf3290bb.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
fix(blocking): return response when server responds before the body is sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar/reqwest#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 16, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: e91333b28aec23a8f13101f31f7db78271eba848
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

Modify "early response" tests to be able to test both a sized request and a chunked request.

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: d9e0523b0ad0e55f03e751ab057fd4c899057217.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
Modify "early response" tests to be able to test both a sized request and a chunked request.
@seanmonstar
seanmonstar merged commit f331e1d into seanmonstar:master Nov 16, 2026
38 of 39 checks passed
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 18, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: 6fd412fccfca097d5a6a4aff6227d9fbcd41398a
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

fix(blocking): return response when server responds before the body is sent

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: def89130b8d38d2b4dc7410e2e89b8a5cf3290bb.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
fix(blocking): return response when server responds before the body is sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar/reqwest#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 18, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: e91333b28aec23a8f13101f31f7db78271eba848
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

Modify "early response" tests to be able to test both a sized request and a chunked request.

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: d9e0523b0ad0e55f03e751ab057fd4c899057217.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
Modify "early response" tests to be able to test both a sized request and a chunked request.
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 20, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: 6fd412fccfca097d5a6a4aff6227d9fbcd41398a
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

fix(blocking): return response when server responds before the body is sent

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: def89130b8d38d2b4dc7410e2e89b8a5cf3290bb.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
fix(blocking): return response when server responds before the body is sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar/reqwest#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 20, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: e91333b28aec23a8f13101f31f7db78271eba848
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

Modify "early response" tests to be able to test both a sized request and a chunked request.

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: d9e0523b0ad0e55f03e751ab057fd4c899057217.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
Modify "early response" tests to be able to test both a sized request and a chunked request.
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 24, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: 6fd412fccfca097d5a6a4aff6227d9fbcd41398a
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

fix(blocking): return response when server responds before the body is sent

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: def89130b8d38d2b4dc7410e2e89b8a5cf3290bb.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
fix(blocking): return response when server responds before the body is sent

The blocking client returns a body error instead of the response when the server responds before a streamed request body is fully sent, as described in seanmonstar/reqwest#3131.

When hyper finishes the request early it drops the body receiver, and the next chunk send in `send_future` fails.  That failure is now reported to `execute_request` (as `BodySendError::RequestFinished`) which goes on to await the response future and return what hyper produced (the response, or hyper's own error) instead of the channel error.  Errors from the caller's `Read` still return immediately as before.

This _could_ be achieved by simply returning `Ok(())` in `async fn send_future(sender: Sender)` in `body.rs` in lieu of returning `BodySendError::RequestFinished` - I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the new `pub(crate) enum BodySendError` type, LMK and I'll switch it over to that, it makes it such that no changes in client.rs are required at all, at a cost of making the case less explicit.  Your call.

One minor behavior change is that if the server drops the connection mid-upload without responding, the error is now hyper's (`is_request()`) instead of "send failed because receiver is gone" (`is_body()`).

Includes regression test for validating repro case, as well as its async counterpart, which already passes without modification, and also a regression test that the ensures the genuine failed `Read` still surfaces as a body error.  I manually verified this on HTTP/2 and the bug also exists there and the same fix applies.

Closes #3131
Byron pushed a commit to GitoxideLabs/gitoxide that referenced this pull request Nov 24, 2026
Port the source worktree commit into `gix-reqwest`, retaining its author.
Retarget Rust crate paths and preserve upstream formatting.

Port validation: library, proxy, redirect, blocking, and client tests pass
with the stable optional features enabled; external TLS-info tests are
excluded.

Reqwest-Patch: e91333b28aec23a8f13101f31f7db78271eba848
Reqwest-PR: seanmonstar/reqwest#3132

Original source message:

Modify "early response" tests to be able to test both a sized request and a chunked request.

<!-- agent -->
Transplanted from seanmonstar/reqwest#3132.
Original commit: d9e0523b0ad0e55f03e751ab057fd4c899057217.
Keeps valid early HTTP responses visible during blocking Git uploads.
The source patch is preserved; local changes are kept in separate commits.

<!-- original message -->
Modify "early response" tests to be able to test both a sized request and a chunked request.
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.

Blocking client returns a body error instead of the response when the server responds before the streamed request body is fully sent

3 participants