Commit Graph

201 Commits

Author SHA1 Message Date
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
Sean McArthur
5da17df97f chore(lib): individually disable tests and examples that aren't updated 2019-07-12 13:44:03 -07:00
Sean McArthur
da9b0319ef refactor(lib): update to 2018 edition 2019-07-09 15:16:01 -07:00
Sean McArthur
01c03db7ea chore(lib): add dyn keyword to trait objects (#1820)
Requires Rust 1.27.
2019-06-03 13:08:13 -07:00
João Oliveira
b342c38f08 fix(server): skip automatic Content-Length header for HTTP 304 responses
Closes #1797
2019-05-07 12:53:25 -07:00
Sean McArthur
e0ec5cad9a fix(client): detect HTTP2 connection closures sooner 2019-04-29 16:17:11 -07:00
Sean McArthur
271bba1667 refactor(error): improve organization of Error kinds
- Placed all cases of "unexpected bytes" errors into the
  `UnexpectedMessage` variant.
- Placed all cases of "unexpected EOF" errors into the
  `IncompleteMessage` variant. Description is now generic about
  "connection closed before message completed", instead of mentioning
  "request" or "response.
- Added `Error::is_incomplete_message()` accessor to help checking for
  unexpected closures.
- Renamed some variants to be clearer when viewing the `Debug` format.
- Collected all "user" errors into an internal `User` enum, to prevent
  forgetting to update the `is_user()` method.
2019-04-26 10:44:40 -07:00
Sean McArthur
f5885f3d5d chore(lib): fix unused_mut warnings from newest nightly 2019-04-23 12:45:19 -07:00
Sean McArthur
42c5efc085 fix(http2): send a GOAWAY when the user's Service::poll_ready errors
The `Error::source()` is searched for an `h2::Error` to allow sending
different error codes in the GOAWAY. If none is found, it defaults to
`INTERNAL_ERROR`.
2019-04-09 12:49:43 -07:00
Sean McArthur
fc18b680a5 feat(http2): check Error::source() for an HTTP2 error code to send in reset 2019-03-25 13:10:41 -07:00
Sean McArthur
3a6080b14a fix(client): coerce HTTP_2 requests to HTTP_11
Closes #1770
2019-02-27 17:00:25 -08:00
Sean McArthur
2b0a5eaa04 refactor(tests): use macro to assign request properties 2019-02-27 17:00:25 -08:00
Sean McArthur
9aa7e99010 fix(http2): revert http2 refactor causing a client hang
This reverts commit 7b7dcc8f68.
2019-01-24 11:10:19 -08:00
Sean McArthur
7b7dcc8f68 refactor(http2): remove extra mpsc trying to work around h2 hang 2019-01-22 15:11:03 -08:00
Sean McArthur
e5135dd6f6 fix(dependencies): disable unneeded optional tokio features
Closes #1739
2019-01-07 15:03:20 -08:00
Sean McArthur
138b1f8a7c test(server): remove unneeded mutex for TestService 2018-12-06 11:06:45 -08:00
Sean McArthur
73345be65f feat(server): add http1_half_close(bool) option
This option determines whether a read EOF should close the connection
automatically. The behavior was to always allow read EOF while waiting
to respond, so this option has a default of `true`.

Setting this option to `false` will allow Service futures to be canceled
as soon as disconnect is noticed.

Closes #1716
2018-11-27 12:31:50 -08:00
Sean McArthur
e455fa2452 fix(client): fix connection leak when Response finishes before Request body
If the Response was received and the body finished while the Request
body was still streaming, the connection could get into a state where it
was never polled again, thus never re-inserting into the connection pool
or being dropped.

Closes #1717
2018-11-21 16:39:47 -08:00
Sean McArthur
9245e9409a fix(header): fix panic when parsing header names larger than 64kb 2018-11-06 14:37:13 -08:00
Sean McArthur
976a77a673 feat(client): add ALPN h2 support for client connectors
- Adds `Connected::negotiated_h2()` method to signal the connection must
  use HTTP2. `Connect` implementations should set this if using ALPN.

If a connection to a host is detected to have been upgraded via ALPN,
any other oustanding connect futures will be canceled, and the waiting
requests will make use of the single HTTP2 connection.

The `http2_only` builder configuration still works the same, not
requiring ALPN at all, and always using only a single connection.
2018-10-31 14:51:29 -07:00
Sean McArthur
5ca2905c84 test(server): server test cleanup 2018-10-26 12:50:27 -07:00
Sean McArthur
2d5af177c1 feat(client): add Resolve, used by HttpConnector
This introduces a `Resolve` trait to describe asynchronous DNS
resolution. The `HttpConnector` can be configured with a resolver,
allowing a user to still use all the functionality of the
`HttpConnector`, while customizing the DNS resolution.

To prevent a breaking change, the `HttpConnector` has its `Resolve`
generic set by default to `GaiResolver`. This is same as the existing
resolver, which uses `getaddrinfo` inside a thread pool.

Closes #1517
2018-10-18 12:10:15 -07:00
Sean McArthur
13d53e1d0c feat(client): adds HttpInfo to responses when HttpConnector is used
- Adds `client::connect::Connected::extra()`, which allows connectors to
  specify arbitrary custom information about a connected transport.

If a connector provides this extra value, it will be set in the
`Response` extensions.

Closes #1402
2018-10-16 14:40:50 -07:00
Sean McArthur
37ec724fd6 fix(http2): add Date header if not present for HTTP2 server responses 2018-10-08 17:52:08 -07:00
Sean McArthur
0cfa7231b2 test(client): update from deprecated export of ConnectFuture 2018-09-27 15:29:57 -07:00
Theodore Cipicchio
24f11a421d fix(http2): allow TE "trailers" request headers
The HTTP/2 spec allows TE headers in requests if the value is
"trailers". Other TE headers are still stripped.

Closes #1642
2018-08-27 10:32:53 -07:00
lambdasqd
1448e4067b fix(server): properly handle keep-alive for HTTP/1.0
Change behaviour of connection or server response when the request is
version 1.0 and the Connection: keep-alive header is not present.

1. If the response is also version 1.0, then connection is closed if the
server keep-alive header is not present.
2. If the response is version 1.1, then the keep-alive header is added
when downgrading to version 1.0.

Closes #1614
2018-08-15 12:10:03 -07:00
Sean McArthur
195fbb2a37 fix(server): coerce responses with HTTP2 version to HTTP/1.1 when protocol is 1.x 2018-08-10 13:08:08 -07:00
Sean McArthur
853266d873 test(server): add http1_only server test 2018-08-10 13:08:08 -07:00
Sean McArthur
6530a00a8e fix(http1): reduce closed connections when body is dropped
If a user makes use of `Body::is_end_stream` to optimize so as to not
need to do make a final poll just to receive `None`, previously the
connection would not have progressed its reading state to a finished
body, and so the connection would be closed.

Now, upon reading any chunk, the connection state will check if it
can know that the body would be finished, and progresses to a body
finished state sooner.

The integration tests were amplified by adding a naive hyper proxy
as a secondary test, which happens to make use of that optimization,
and thus caught the issue.
2018-07-23 09:39:19 -07:00
Sean McArthur
1f95f58837 chore(error): improve message about incomplete parsed messages 2018-06-25 17:29:40 -07:00
Sean McArthur
e61fe54093 test(server): fix unused result from block_on 2018-06-25 11:48:52 -07:00
Sean McArthur
6848ba63fb test(server): use current_thread instead of rt::run with http2 tests 2018-06-25 11:35:57 -07:00
Sean McArthur
2a3844acc3 feat(client): enable CONNECT requests through the Client
While the upgrades feature enabled HTTP upgrades in both and the server and client, and the goal was for `CONNECT` requests to work as well, only the server could use them for `CONNECT`. The `Client` had some specific code rejecting `CONNECT` requests, and this removes it and prepares the `Client` to handle them correctly.
2018-06-22 21:00:28 -07:00
Sean McArthur
e4ebf44823 chore(tests): change tests to use current_thread runtime 2018-06-18 12:30:56 -07:00