If a connection has any error besides reading, a streaming body
sometimes wouldn't be notified. This change makes it so that when a
connection task is closing because of any error, an existing body
channel is also notified.
Closes#3253
`client::conn::{SendRequest, Connection, Builder, handshake}` are deprecated as they are removed in 1.0.
This adds the `deprecated` feature to Cargo, and only when `hyper/deprecated` is enabled will these warnings be emitted.
Co-authored-by: KOVACS Tamas <ktamas@fastmail.fm>
This patch backports client/conn/http1 and http2 modules from 1.0 to
ease transition. It allows code still using 0.14.x to switch to the
per-version Connection types available in 1.0.
Closes#3053
Co-authored-by: KOVACS Tamas <ktamas@fastmail.fm>
Add `capture_connection` functionality. This allows callers to retrieve the `Connected` struct of the connection that was used internally by Hyper. This is in service of https://github.com/hyperium/hyper/issues/2605.
Although this uses `http::Extensions` under the hood, the API exposed explicitly hides that detail.
Add `poison` method to `Connected`. This allows callers to mark a connection as poisoned which prevents the pool from reusing it on subsequent requests. `is_open` will consider poisoning prior to returning a connection to the pool.
Previously, `to_bytes` would reserve extra space if after two chunks,
there was more remaining. It used to reserve however much space the peer
advertized.
This changes now only reserves up to ~16kb. This way, a slow message
with a big body doesn't reserve so much memory, until the data has
actually been received.
The existing warning to check for a length before calling the function
is still the best approach.
There exists a race condition in ClientTask::poll() when the request
that is sent via h2::client::send_request() is pending open. A task will
be spawned to wait for send capacity on the sendstream. Because this
same stream is also stored in the pending member of
h2::client::SendRequest the next iteration of the poll() loop can call
poll_ready() and call wait_send() on the same stream passed into the
spawned task.
Fix this by always calling poll_ready() after send_request(). If this
call to poll_ready() returns Pending save the necessary context in
ClientTask and only spawn the task that will eventually resolve to the
response after poll_ready() returns Ok.
Closes#2419