Repository navigation
fix(blocking): return response when server responds before the body is sent - #3132
Conversation
…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
|
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
left a comment
There was a problem hiding this comment.
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 (edited) |
|
I rechecked the current diff. The early-response regression now runs with both |
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
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
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
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
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
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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_futurefails. That failure is now reported toexecute_request(asBodySendError::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'sReadstill return immediately as before.This could be achieved by simply returning
Ok(())inasync fn send_future(sender: Sender)inbody.rsin lieu of returningBodySendError::RequestFinished- I opted to make this specific case explicit rather than hiding it, but if you'd prefer the cleaner API without the newpub(crate) enum BodySendErrortype, LMK and I'll switch it over to that, it makes it such that no changes inclient.rsare 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
Readstill 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.