Commit Graph

185 Commits

Author SHA1 Message Date
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
2a19ab74ed feat(http1): Make HTTP/1 support an optional feature
cc #2251

BREAKING CHANGE: This puts all HTTP/1 methods and support behind an
  `http1` cargo feature, which will not be enabled by default. To use
  HTTP/1, add `features = ["http1"]` to the hyper dependency in your
  `Cargo.toml`.
2020-11-17 10:42:20 -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
Pedro Calado
f288641792 test(server): test server keep alive by counting number of pings
Add `http2_keep_alive_count_server_pings` which tests if 3 pings are
received under 5 seconds with keep alive interval set to 1 second.
2020-10-29 09:02:26 -07:00
Dirkjan Ochtman
aac0e2dd57 refactor(body): use HttpBody with extra bounds instead of Payload trait 2020-05-14 13:26:39 -07: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
Sean McArthur
c4bb4db5c2 fix(http1): only send 100 Continue if request body is polled
Before, if a client request included an `Expect: 100-continue` header,
the `100 Continue` response was sent immediately. However, this is
problematic if the service is going to reply with some 4xx status code
and reject the body.

This change delays the automatic sending of the `100 Continue` status
until the service has call `poll_data` on the request body once.
2020-01-28 17:32:58 -08:00
Sean McArthur
1881db6391 fix(http1): remove panic for HTTP upgrades that have been ignored (#2115)
Closes #2114
2020-01-23 16:41:40 -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
b0060f277e chore(CI): enable GitHub Actions 2019-12-05 13:12:35 -08:00
Sean McArthur
0b03b73053 feat(lib): rename unstable-stream feature to stream and enable by default
Closes #2034
2019-12-04 17:09:10 -08:00
Sean McArthur
a738d03fd3 chore(dependencies): update to http-body 0.3 2019-12-04 16:48:06 -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
ca5836f1ec fix(server): ignore expect-continue with no body in debug mode
Closes #1843
2019-10-18 15:44:01 -07:00
Sean McArthur
a1fe383c9d refactor(http1): notice eof in the try_keep_alive method 2019-10-18 15:16:07 -07:00
Sean McArthur
2d6bbd2cd8 chore(ci): re-enable CI running on beta 2019-10-18 15:16:07 -07:00
Sean McArthur
7e31fd88a8 feat(server): change http1_half_close option default to disabled
Detecting a read hangup is a useful way to determine that a connection
has closed. It's also possible that a client shuts down its read half
without closing the connection, but this is rarer. Thus, by default,
hyper will now assume a read EOF means the connection has closed.

BREAKING CHANGE: The server's behavior will now by default close
  connections when receiving a read EOF. To allow for clients to close
  the read half, call `http1_half_close(true)` when configuring a
  server.
2019-10-18 13:34:23 -07:00
Taiki Endo
053d6497bd chore(dependencies): update tokio, h2, and tower-make 2019-09-23 12:45:37 -07:00
Sean McArthur
b3e5506261 feat(server): introduce Accept trait
The `Accept` trait is used by the server types to asynchronously accept
incoming connections. This replaces the previous usage of `Stream`.

BREAKING CHANGE: Passing a `Stream` to `Server::builder` or
  `Http::serve_incoming` must be changed to pass an `Accept` instead. The
  `stream` optional feature can be enabled, and the a stream can be
  converted using `hyper::server:🉑:from_stream`.
2019-09-05 14:47:39 -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
Lucio Franco
ec520d5602 feat(service): use tower_service::Service for hyper::service 2019-08-20 12:01:06 -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
Jakub Wieczorek
b831ae1870 test(server): Update and re-enable the tests/server.rs test
These tests were temporarily disabled during the migration to the
`std::future::Future` type that's part of the stable Rust now.

This commit updates the tests after the breaking changes and makes them
pass again.
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
Jakub Wieczorek
d683e13ecb test(client): Re-enable the tests/client.rs test
These tests were temporarily disabled during the migration to the
`std::future::Future` type that's part of the stable Rust now.

This commit updates the tests after the breaking changes and makes them
pass again.
2019-07-23 10:22:26 -07:00