125 Commits

Author SHA1 Message Date
Sean McArthur
bb3af17ce1 feat(client): remove higher-level hyper::Client (#2941)
This removes the following types and methods from hyper:

- `Client`
- `Error::is_connect()`

BREAKING CHANGE: A pooling client is in the hyper-util crate.
2022-08-15 09:15:59 -07:00
Sean McArthur
0c8ee93d7f feat(client,server): remove tcp feature and code (#2929)
This removes the `tcp` feature from hyper's `Cargo.toml`, and the code it enabled:

- `HttpConnector`
- `GaiResolver`
- `AddrStream`

And parts of `Client` and `Server` that used those types. Alternatives will be available in the `hyper-util` crate.

Closes #2856 
Co-authored-by: MrGunflame <mrgunflame@protonmail.com>
2022-07-29 10:07:09 -07:00
Sean McArthur
d4b5bd4ee6 fix(http1): trim obs-folded headers when unfolding (#2926) 2022-07-27 07:00:53 -07:00
Sean McArthur
3660443108 test(client,server): add back tests around streaming bodies (#2905) 2022-06-29 06:39:21 -07:00
Oddbjørn Grødem
ce72f73464 feat(lib): remove stream cargo feature (#2896)
Closes #2855
2022-06-23 15:12:24 -07:00
Adam C. Foltzer
b2052a433f feat(ext): support non-canonical HTTP/1 reason phrases (#2792)
Add a new extension type `hyper::ext::ReasonPhrase` gated by either the `ffi` or `http1` Cargo
features. When enabled, store any non-canonical reason phrases in this extension when parsing
responses, and write this reason phrase instead of the canonical reason phrase when emitting
responses.

Reason phrases are a disused corner of the spec that implementations ought to treat as opaque blobs
of bytes. Unfortunately, real-world traffic sometimes does depend on being able to inspect and
manipulate them.

Non-canonical reason phrases are checked for validity at runtime to prevent invalid and dangerous
characters from being emitted when writing responses. An `unsafe` escape hatch is present for hyper
itself to create reason phrases that have been parsed (and therefore implicitly validated) by
httparse.
2022-06-08 15:57:33 -07:00
Anthony Ramine
1f0c177b35 feat(http1): implement obsolete line folding (#2734)
The client now has an option to allow parsing responses with obsolete line folding in headers. The option is off by default, since the spec recommends to reject such things if you can.
2022-02-09 12:59:23 -08:00
Sean McArthur
1010614a0d test(client): refactor client helper macro to handle options better 2021-11-24 14:26:26 -08:00
Sean McArthur
9d253d3168 test(client): fix extra semi-colon warning in helper macro 2021-08-04 11:45:03 -07:00
Anthony Ramine
5442b6fadd feat(http2): Implement Client-side CONNECT support over HTTP/2 (#2523)
Closes #2508
2021-05-24 18:20:44 +00:00
Geoffry Song
be9677a1e7 feat(http2): allow HTTP/2 requests by ALPN when http2_only is unset (#2527) 2021-05-19 10:01:20 -07:00
Adam C. Foltzer
960a69a587 feat(error): add Error::is_parse_too_large and Error::is_parse_status methods (#2538)
The discussion in #2462 opened up some larger questions about more comprehensive approaches to the
error API, with the agreement that additional methods would be desirable in the short term. These
methods address an immediate need of our customers, so I would like to get them in first before we
flesh out a future solution.

One potentially controversial choice here is to still return `true` from `is_parse_error()` for
these variants. I hope the naming of the methods make it clear that the new predicates are
refinements of the existing one, but I didn't want to change the behavior of `is_parse_error()`
which would require a major version bump.
2021-05-12 18:30:28 -07:00
Anthony Ramine
68d4e4a3db feat(client): allow HTTP/0.9 responses behind a flag (#2473)
Fixes #2468
2021-03-26 11:25:00 -07:00
Vincent Ricard
48fdaf1606 fix(headers): Support multiple Content-Length values on same line (#2471)
Closes #2470
2021-03-19 10:38:58 -07:00
Ivan Nikulin
2c8121f173 fix(client): HTTP/1 client "Transfer-Encoding" repair code would panic (#2410)
Closes #2409
2021-01-26 10:36:58 -08:00
Sean McArthur
fad42acc79 feat(lib): Upgrade to Tokio 1.0 (#2369)
Closes #2370
2020-12-23 10:36:12 -08:00
Alex Rebert
1dd761c87d fix(http1): ignore chunked trailers (#2357)
Previously, hyper returned an "Invalid chunk end CR" error on chunked
responses with trailers, as described in RFC 7230 Section 4.1.2. This
commit adds code to ignore the trailers.

Closes #2171
2020-12-15 14:23:07 -08:00
Sean McArthur
121c33132c feat(upgrade): Moved HTTP upgrades off Body to a new API (#2337)
Closes #2086

BREAKING CHANGE: The method `Body::on_upgrade()` is gone. It is
  essentially replaced with `hyper::upgrade::on(msg)`.
2020-11-19 16:36:12 -08:00
Sean McArthur
1b9af22fa0 Tokio 0.3 Upgrade (#2319)
Co-authored-by: Urhengulas <johann.hemmann@code.berlin>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-11-05 17:17:21 -08:00
Sean McArthur
9a8413d910 feat(http2): add HTTP2 keep-alive support for client and server
This adds HTTP2 keep-alive support to client and server connections
based losely on GRPC keep-alive. When enabled, after no data has been
received for some configured interval, an HTTP2 PING frame is sent. If
the PING is not acknowledged with a configured timeout, the connection
is closed.

Clients have an additional option to enable keep-alive while the
connection is otherwise idle. When disabled, keep-alive PINGs are only
used while there are open request/response streams. If enabled, PINGs
are sent even when there are no active streams.

For now, since these features use `tokio::time::Delay`, the `runtime`
cargo feature is required to use them.
2020-03-20 14:20:45 -07:00
Sean McArthur
d838d54fdf fix(http1): try to drain connection buffer if user drops Body 2020-03-10 12:57:36 -07:00
Sean McArthur
a82fd6c94a feat(client): rename client::Builder pool options (#2142)
- Renamed `keep_alive_timeout` to `pool_idle_timeout`.
- Renamed `max_idle_per_host` to `pool_max_idle_per_host`.
- Deprecated `keep_alive(bool)` due to confusing name. To disable the
  connection pool, call `pool_max_idle_per_host(0)`.
2020-02-27 14:25:06 -08:00
Sean McArthur
dd02254ae8 style(lib): apply latest rustfmt 2020-02-06 11:41:25 -08:00
Linus Färnstrand
de7418da2f style(lib): use just std instead of ::std in paths (#2101) 2020-01-29 10:25:57 -08:00
danieleades
0eaf304644 style(lib): address most clippy lints 2020-01-03 09:40:32 -08:00
Vivek Ghaisas
35825c4614 style(comments): correct some typos in Rust code comments 2019-12-20 10:16:36 -08:00
Sean McArthur
4b6099c7aa feat(body): implement HttpBody for Request and Response
When the body type of a `Request` or `Response` implements `HttpBody`,
the `Request` or `Response` itself now implements `HttpBody`.

This allows writing things like `hyper::body::aggregate(req)` instead of
`hyper::body::aggregate(req.into_body())`.

Closes #2067
2019-12-13 10:48:30 -08:00
Sean McArthur
cb71d2cdbd fix(http1): fix response with non-chunked transfer-encoding to be close-delimited
Closes #2058
2019-12-12 14:26:56 -08:00
Sean McArthur
8ba9a8d2c4 feat(body): add body::aggregate and body::to_bytes functions
Adds utility functions to `hyper::body` to help asynchronously
collecting all the buffers of some `HttpBody` into one.

- `aggregate` will collect all into an `impl Buf` without copying the
  contents. This is ideal if you don't need a contiguous buffer.
- `to_bytes` will copy all the data into a single contiguous `Bytes`
  buffer.
2019-12-06 10:03:05 -08:00
Sean McArthur
5a59875742 feat(body): replace Chunk type with Bytes
Closes #1931

BREAKING CHANGE: All usage of `hyper::Chunk` should be replaced with
  `bytes::Bytes` (or `hyper::body::Bytes`).
2019-12-05 17:22:13 -08:00
Sean McArthur
0dc89680cd style(lib): run rustfmt and enforce in CI 2019-12-05 13:55:17 -08:00
Sean McArthur
4d7a2266b8 feat(client): change connectors to return an impl Connection
Instead of returning a tuple `(impl AsyncRead + AsyncWrite, Connected)`,
this adds a new trait, `hyper::client::connect::Connection`, which
allows querying the connection type for a `Connected`.

BREAKING CHANGE: Connectors no longer return a tuple of
  `(T, Connected)`, but a single `T: Connection`.
2019-12-04 16:15:28 -08:00
Sean McArthur
319e8aee15 feat(client): remove Destination for http::Uri in connectors
BREAKING CHANGE: All usage of `hyper::client::connect::Destination`
  should be replaced with `http::Uri`.
2019-12-04 16:15:28 -08:00
Sean McArthur
cb3f39c2dc feat(lib): update Tokio, bytes, http, h2, and http-body 2019-12-04 10:56:34 -08:00
Daniel Johnson
71d088d3d0 chore(dependencies): update futures to 0.3.1 2019-11-14 10:04:16 -08:00
Sean McArthur
9d9233ce7c feat(client): change Resolve to be Service<Name>
Closes #1903

BREAKING CHANGE: The `Resolve` trait is gone. All custom resolves should
  implement `tower::Service` instead.

  The error type of `HttpConnector` has been changed away from
  `std::io::Error`.
2019-11-12 13:08:39 -08:00
Sean McArthur
d67e49f149 feat(client): change Connect trait into an alias for Service
The `Connect` trait is now essentially an alias for
`Service<Destination>`, with a blanket implementation as such, and is
sealed.

Closes #1902

BREAKING CHANGE: Any manual implementations of `Connect` must instead
  implement `tower::Service<Destination>`.
2019-10-22 14:40:23 -07:00
Sean McArthur
a1fe383c9d refactor(http1): notice eof in the try_keep_alive method 2019-10-18 15:16:07 -07:00
Taiki Endo
053d6497bd chore(dependencies): update tokio, h2, and tower-make 2019-09-23 12:45:37 -07:00
Sean McArthur
0867ad5c15 fix(client): allow client GET requests with explicit body headers
Closes #1925
2019-09-04 15:22:30 -07:00
Sean McArthur
62a96c077b feat(body): change Sender::send_data to an async fn.
The previous version is renamed to `try_send_data`.

BREAKING CHANGE: Usage of `send_data` should either be changed to
  async/await or use `try_send_data`.
2019-08-30 16:04:07 -07:00
Sean McArthur
049b5132db feat(client): change GaiResolver to use a global blocking threadpool
BREAKING CHANGE: Calls to `GaiResolver::new` and `HttpConnector::new` no
  longer should pass an integer argument for the number of threads.
2019-08-29 14:16:43 -07:00
Sean McArthur
2664cf505f refactor(tests): update to newest tokio-timer 2019-08-29 13:50:55 -07:00
Lucio Franco
79c32f8953 feat(body): Update Payload to be a trait alias of http_body::Body (#1908) 2019-08-22 14:13:27 -07:00
lzutao
fc7f81b67c style(lib): use rust 2018 edition idioms (#1910) 2019-08-21 11:22:07 -07:00
lzutao
ae75b3a732 chore(lib): remove async_await feature gate (#1909)
`async_await` is stabilized in rust-lang/rust#63209.
2019-08-21 11:09:14 -07:00
Sean McArthur
53a437c382 chore(tests): fixup re-enabled tests 2019-08-19 17:55:37 -07:00
Jakub Wieczorek
821fa03c2a test(client): Uncomment failing tests and make them #[ignore]d. 2019-08-19 16:35:01 -07:00
Douman
4920f5e264 chore(dependencies): Upgrade tokio 2019-08-19 09:00:21 -07:00
Sean McArthur
46749c14c6 test(client): fix background thread panics 2019-07-23 11:03:14 -07:00