Commit Graph

1681 Commits

Author SHA1 Message Date
Sam Rijs
a12f7beed9 refactor(lib): convert to futures 0.2.0-beta (#1470) 2018-03-29 13:32:44 -07:00
Sean McArthur
5db85316a1 refactor(client): replace signal mod with want crate 2018-03-19 11:43:47 -07:00
Sean McArthur
06f0126fad refactor(lib): clean up unused dependencies 2018-03-19 11:43:47 -07:00
Sam Reis
27b8db3af8 feat(lib): convert to use tokio 0.1
BREAKING CHANGE: All uses of `Handle` now need to be new-tokio `Handle`.

Co-authored-by: Sean McArthur <sean@seanmonstar.com>
2018-03-19 11:43:47 -07:00
Sean McArthur
8c52c2dfd3 feat(client): redesign the Connect trait
The original `Connect` trait had some limitations:

- There was no way to provide more details to the connector about how to
  connect, other than the `Uri`.
- There was no way for the connector to return any extra information
  about the connected transport.
- The `Error` was forced to be an `std::io::Error`.
- The transport and future had `'static` requirements.

As hyper gains HTTP/2 support, some of these things needed to be
changed. We want to allow the user to configure whether they hope to
us ALPN to start an HTTP/2 connection, and the connector needs to be
able to return back to hyper if it did so.

The new `Connect` trait is meant to solve this.

- The `connect` method now receives a `Destination` type, instead of a
  `Uri`. This allows us to include additional data about how to connect.
- The `Future` returned from `connect` now must be a tuple of the
  transport, and a `Connected` metadata value. The `Connected` includes
  possibly extra data about what happened when connecting.

BREAKING CHANGE: Custom connectors should now implement `Connect`
  directly, instead of `Service`.

  Calls to `connect` no longer take `Uri`s, but `Destination`. There
  are `scheme`, `host`, and `port` methods to query relevant
  information.

  The returned future must be a tuple of the transport and `Connected`.
  If no relevant extra information is needed, simply return
  `Connected::new()`.

Closes #1428
2018-03-19 11:43:47 -07:00
Sean McArthur
fbc449e49c feat(body): introduce an Entity trait to represent bodies
This dedicated `Entity` trait replaces the previous `Stream<Item=impl
AsRef<[u8]>, Error=hyper::Error>`. This allows for several improvements
immediately, and prepares for HTTP2 support.

- The `Entity::is_end_stream` makes up for change away from
  `Option<Body>`, which was previously used to know if the body should be
  empty. Since `Request` and `Response` now require a body to be set,
  this method can be used to tell hyper that the body is actually empty.

  It also provides the possibility of slight optimizations when polling
  for data, by allowing to check `is_end_stream` before polling again.
  This can allow a consumer to know that a body stream has ended without
  polling for `None` afterwards.

- The `Entity::content_length` method allows a body to automatically
  declare a size, in case a user doesn't set a `Content-Length` or
  `Transfer-Encoding` header.

- It's now possible to send and receive trailers, though this will be
  for HTTP2 connections only.

By being a trait owned by hyper, new methods can be added later as new
features are wanted (with default implementations).

The `hyper::Body` type now implements `Entity` instead of `Stream`,
provides a better channel option, and is easier to use with custom
streams via `Body::wrap_stream`.

BREAKING CHANGE: All code that was assuming the body was a `Stream` must
  be adjusted to use an `Entity` instead.

  Using `hyper::Body` as a `Stream` can call `Body::into_stream`
  to get a stream wrapper.

  Passing a custom `impl Stream` will need to either implement
  `Entity`, or as an easier option, switch to `Body::wrap_stream`.

  `Body::pair` has been replaced with `Body::channel`, which returns a
  `hyper::body::Sender` instead of a `futures::sync::mpsc::Sender`.

Closes #1438
2018-03-19 11:43:47 -07:00
Sean McArthur
3cd48b45fb feat(lib): replace types with those from http crate
BREAKING CHANGE: `Method`, `Request`, `Response`, `StatusCode`,
  `Version`, and `Uri` have been replaced with types from the `http`
  crate. The `hyper::header` module is gone for now.

  Removed `Client::get`, since it needed to construct a `Request<B>`
  with an empty body. Just use `Client::request` instead.

  Removed `compat` cargo feature, and `compat` related API.
2018-03-19 11:43:47 -07:00
Sean McArthur
a37e6b59e6 fix(lib): remove deprecated tokio-proto APIs
BREAKING CHANGE: Many of these APIs have been deprecated for a while,
  check the documentation for the recommended way to use hyper now.
2018-03-19 11:37:32 -07:00
Sean McArthur
dbfc45bf5c chore(lib): start 0.12.x branch 2018-03-19 11:37:32 -07:00
Yusuke Sasaki
eb10567927 fix(server): prevent to output Transfer-encoding when server upgrade (#1465) 2018-03-19 10:27:54 -07:00
Sean McArthur
91b9700862 refactor(client): only spawn pooled in executor if not ready when response recieved 2018-03-13 18:46:52 -07:00
Sean McArthur
26ec18a282 refactor(client): make conn::ResponseFuture implement Send 2018-03-13 16:34:12 -07:00
Sean McArthur
dcfebc6308 chore(dependencies): update minimum Rust version to 1.21, because of tokio-core 2018-03-12 14:31:05 -07:00
Sean McArthur
f680fca9ec tests(client): fix flaking conn_reset test 2018-03-12 14:28:59 -07:00
Sean McArthur
d58aa73246 feat(server): add upgrade support to lower-level Connection API (#1459)
Closes #1323
2018-03-09 10:05:27 -08:00
Sean McArthur
eb15c660c1 Merge pull request #1454 from hyperium/client-connection
feat(client): introduce lower-level Connection API
2018-03-07 16:31:18 -08:00
Sean McArthur
1207c2b624 feat(client): introduce lower-level Connection API
Closes #1449
2018-03-07 14:26:52 -08:00
Sean McArthur
0786ea1f87 v0.11.22 2018-03-07 12:56:57 -08:00
Sean McArthur
bfcdbd9f86 fix(client): return error if Request has CONNECT method
The higher-level `Client` has never supported `CONNECT` requests,
but it used to send them, and then handle the responses incorrectly.
Now, it will return an error immediately instead of misbehaving.
2018-03-06 10:48:59 -08:00
Sean McArthur
33a385c6b6 feat(client): add Config::set_host option
If set to false, the `Client` will no longer automatically set the
`Host` header if absent.
2018-03-06 10:37:40 -08:00
Sean McArthur
3e87eb48b1 tests(client): fix client test warnings 2018-03-05 15:37:50 -08:00
Sean McArthur
994bcd193c tests(client): make retryable request tests more reliable 2018-03-05 15:05:24 -08:00
Klaus Purer
49fcb0663c fix(dependencies): require tokio-core 0.1.11 2018-03-05 10:32:31 -08:00
Sean McArthur
9990e273f6 test(server): fix streaming_body incorrect test 2018-03-01 14:13:02 -08:00
Sean McArthur
4351ed1d13 chore(client): fix unused_mut warning in 1.18 2018-02-28 16:45:43 -08:00
Sean McArthur
f7102ae6c4 v0.11.21 2018-02-28 15:17:02 -08:00
Sean McArthur
2fa0c845b5 fix(client): check conn is closed in expire interval 2018-02-28 15:16:01 -08:00
Sean McArthur
4aab54eebc Merge branch 'pool-expired' 2018-02-28 14:58:22 -08:00
Sean McArthur
727b74797e fix(client): schedule interval to clear expired idle connections
Currently only works if Client is built with a `Handle`, and not a
custome executor, since a `Handle` is required to create a tokio
Interval.
2018-02-28 14:57:06 -08:00
Sean McArthur
13741f5145 fix(client): never call connect if idle connection is available
The HttpConnector's connect future was lazy, but if any custom connector
did not use a lazy future, then a connect would always be started, even
if an idle connection was available.
2018-02-28 14:18:37 -08:00
Sean McArthur
1223fc28ee wip 2018-02-28 13:58:38 -08:00
Sean McArthur
ad7763072c v0.11.20 2018-02-26 15:07:38 -08:00
Sean McArthur
8743c86660 refactor(server): adjust accept error debug log 2018-02-26 14:52:16 -08:00
Sean McArthur
43e8ec4622 Merge pull request #1450 from klausi/sleep_on_errors
fix(server): Sleep on socket IO errors
2018-02-26 13:41:21 -08:00
Klaus Purer
4927f143a2 Merge branch 'master' into sleep_on_errors 2018-02-25 22:24:03 +01:00
Sean McArthur
3fa191a267 feat(request): add Request::body_mut() method 2018-02-24 12:16:25 -08:00
Sean McArthur
2f45d5394a feat(body): add Body::is_empty() method 2018-02-24 11:54:02 -08:00
Klaus Purer
3a36eb5596 fix(server): Make sleep_on_errors configurable and use it in example 2018-02-24 16:19:01 +01:00
Klaus Purer
68458cde57 fix(server): Sleep on socket IO errors 2018-02-24 16:03:46 +01:00
Sean McArthur
b79f8d32b5 chore(ci): don't build docs on rust 1.18 2018-02-21 13:45:54 -08:00
Sean McArthur
36eabbb18f v0.11.19 2018-02-21 13:15:57 -08:00
Sean McArthur
6d5bb85700 docs(server): add example to serve_connection 2018-02-21 13:14:42 -08:00
Sean McArthur
e6647aa679 Merge pull request #1444 from mikeyhew/docs-basic-fromstr
docs(headers): document the fact that <Basic as FromStr>::from_str takes a base-64 encoded string
2018-02-20 13:55:30 -08:00
Michael Hewson
ba6fcf33b0 docs(headers): document the fact that <Basic as FromStr>::from_str takes a base-64 encoded string
I couldn't figure out why my "username:password" strings kept failing to parse
into a Basic auth header, until I realized that the implementation expects
it to be base-64 encoded, which would be the case if it was coming from HTTP.
I'm not sure if this is the best place to document it, but hopefully it will
make it more clear for other people / me when I forget.

Perhaps a better approach would be to document somewhere that all `FromStr` impls for
headers are there for parsing request headers, and not really for creating them.
2018-02-19 23:56:55 -05:00
Sean McArthur
77adab4ebf fix(client): prevent empty bodies sending transfer-encoding for GET, HEAD 2018-02-16 15:22:06 -08:00
Sean McArthur
dd79a4a0e0 chore(client): fix unused_mut in 1.18 2018-02-15 14:54:56 -08:00
Sean McArthur
6244526a5b chore(tests): fix not-compiling tests 2018-02-15 12:55:02 -08:00
Sean McArthur
39e03a91e2 perf(server): set TCP keepalive when default listener is used 2018-02-15 12:49:52 -08:00
Sean McArthur
6ef22da8ea perf(client): set TCP keepalive when default connector is used 2018-02-15 12:40:38 -08:00
Sean McArthur
ee61ea9adf feat(client): Client will retry requests on fresh connections
If a request sees an error on a pooled connection before ever writing
any bytes, it will now retry with a new connection.

This can be configured with `Config::retry_canceled_requests(bool)`.
2018-02-15 12:04:58 -08:00