Commit Graph

293 Commits

Author SHA1 Message Date
Alexander Mielczarek
078ed82dd5 feat(client): add conn::Builder::max_buf_size()
This allows users to configure a limit to client connections' read and
write buffers.

Closes #1748
2019-01-24 10:59:24 -08:00
Sean McArthur
c328c62ec2 fix(client): parse IPv6 hosts correctly in HttpConnector 2019-01-23 11:24:26 -08:00
Sean McArthur
83dad03a81 test(client): update tests for http::Uri::host fix 2019-01-22 15:02:23 -08:00
Sean McArthur
c69d1094b3 refactor(lib): replace 'try' macro with '?' 2019-01-18 14:29:12 -08:00
Lucio Franco
c809542c83 feat(client): add Destination::try_from_uri constructor
This change adds a try_from_uri function for creating Destinations
outside of the hyper crate. The Destination can only be built if the
uri contains a valid authority and scheme as these are required to
build a Destination.
2019-01-15 09:45:30 -08:00
Linus Färnstrand
be5ec45571 feat(client): Add useful trait impls to Name 2019-01-11 10:01:28 -08:00
Sean McArthur
8842da9184 docs(client): touch ups for Client, Builder, and connect types 2019-01-10 12:18:16 -08:00
Linus Färnstrand
607c4da0b9 feat(client): add FromStr impl for Name 2019-01-10 09:39:26 -08:00
Sean McArthur
1d253b4d47 fix(rt): prevent fallback reactor thread from being created accidentally
Switches from `Handle::current()` to `Handle::default()`.
2018-12-18 12:44:08 -08:00
Sean McArthur
f8f926c14c doc(client): document that http2_only needs Prior Knowledge or ALPN
configured.

Closes #1698
2018-12-11 15:41:01 -08:00
Sean McArthur
3287a0cdab test(client): fix pool tests compilation errors 2018-12-06 16:55:24 -08:00
Sean McArthur
010a886516 refactor(client): remove dead exec function 2018-12-05 17:01:07 -08:00
Sean McArthur
4b3747110a refactor(client): clean up client config fields 2018-12-05 12:17:03 -08:00
Sean McArthur
65788fe7fe test(client): disable happy eyeballs tests except in CI 2018-12-05 10:57:37 -08:00
Jeff Labonte
69368f433f refactor(client): update from deprecated Uri::port to port_part (#1722) 2018-11-26 10:06:40 -08:00
Rick Richardson
2e7250b669 feat(client): add http1_read_buf_exact_size Builder option
This changes the read buffer strategy from being adaptive to always
using an exact size for the buffer.
2018-11-21 14:07:21 -08:00
Sean McArthur
95446cc338 feat(client): add client::conn::Builder::executor method 2018-11-16 16:32:09 -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
deaa5d1aa9 chore(client): fix infinite recursion in TokioThreadpoolGaiResolver::new 2018-10-23 13:34:47 -07:00
Sean McArthur
34d780acd0 feat(dns): export client::connect::dns module, and
`TokioThreadpoolGaiResolver` type.
2018-10-23 12:49:56 -07:00
Steven Fackler
1e8d6439cf feat(dns): tokio_threadpool::blocking resolver
Unlike the default resolver, this avoids spawning extra dedicated
threads but only works on the multi-threaded Tokio runtime.

Closes #1676
2018-10-23 09:57:04 -07:00
Sean McArthur
6fe532da4c feat(client): allow Connected::extra to be chained to connectors can be composed 2018-10-18 15:51:19 -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
efd2c281b8 refactor(client): add comments about the checkout vs connect race 2018-09-28 12:50:45 -07:00
Sean McArthur
09156a70a6 refactor(lib): remove build script features since minimum version is higher 2018-09-28 12:02:21 -07:00
Sean McArthur
b0c132023c refactor(client): change retryable request future from boxed to 'impl Future' 2018-09-28 12:01:37 -07:00
Sean McArthur
192348d7ef refactor(client): don't allocate PoolInner if pool is disabled 2018-09-28 11:13:22 -07:00
Sean McArthur
bddc2d5040 refactor(client): clarify some code in send_request 2018-09-28 10:24:19 -07:00
Sean McArthur
af23dda2e9 refactor(client): breakout checkout and connect race into separate function 2018-09-28 10:24:19 -07:00
Sean McArthur
5e159a58b4 refactor(client): breakout connect_to future into separate function 2018-09-28 10:24:19 -07:00
Sean McArthur
af5e4f3ec2 fix(client): allow calling Destination::set_host with IPv6 addresses
Closes #1661
2018-09-27 17:34:05 -07:00
Sean McArthur
5bfc110538 refactor(client): improve connect module structure 2018-09-27 14:50:11 -07:00
Sean McArthur
a3c44ded55 feat(client): add max_idle_per_host configuration option
Setting this will cap the amount of idle connections kept around for a
specific host. This defaults to no limit (`usize::MAX`).
2018-08-22 12:28:49 -07:00
Sean McArthur
6e8417e08f refactor(lib): use type macro to detect impl Trait 2018-08-07 21:00:02 -07:00
Niv Kaminer
9f8add6056 chore(client): place the use of new rust features behind cfg 2018-08-07 19:36:00 -07:00
Niv Kaminer
4290b8bba4 perf(client): replace usage of Box<Trait> with impl Trait 2018-08-07 19:36:00 -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
Eli Snow
13862d11ad feat(client): add ability to include SO_REUSEADDR option on sockets
Closes #1599
2018-07-11 12:13:59 -07:00
Hrvoje Ban
02a9c29e2e feat(client): implement rfc 6555 (happy eyeballs)
Update client connector to attempt a parallel connection using
alternative address family, if connection using preferred address family
takes too long.

Closes: #1316
2018-07-10 13:43:03 -07:00
Jonas Platte
51223efb8a docs(lib): Fix some typos 2018-07-08 10:10:12 -07:00
Sean McArthur
f2d464ac79 fix(client): try to reuse connections when pool checkout wins
If a checkout wins, meaning an idle connection became available before
a connect future completed, instead of just dropping the connect future,
it spawns it into the background executor to allow being placed into
the pool on completion.
2018-06-28 12:43:56 -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
61f31b5a4a doc(client): show spawning a client future, clarify lazy in client example 2018-06-18 17:02:57 -07:00
Sean McArthur
482a5f589e fix(lib): return an error instead of panic if execute fails
If executing an internal task fails, a new variant of `hyper::Error` is
returned to the user, with improved messaging.

If a non-critical task fails to spawn, it no longer panics, instead just
logging a warning.

Closes #1566
2018-06-18 16:01:04 -07:00
Sean McArthur
27db8b0061 feat(client): add set_scheme, set_host, and set_port for Destination
Closes #1564
2018-06-18 15:21:41 -07:00
Sean McArthur
e4ebf44823 chore(tests): change tests to use current_thread runtime 2018-06-18 12:30:56 -07:00
Sean McArthur
fea29b29e2 feat(http1): Add higher-level HTTP upgrade support to Client and Server (#1563)
- Adds `Body::on_upgrade()` that returns an `OnUpgrade` future.
- Adds `hyper::upgrade` module containing types for dealing with
  upgrades.
- Adds `server::conn::Connection::with_upgrades()` method to enable
  these upgrades when using lower-level API (because of a missing
  `Send` bound on the transport generic).
- Client connections are automatically enabled.
- Optimizes request parsing, to make up for extra work to look for
  upgrade requests.
  - Returns a smaller `DecodedLength` type instead of the fatter
    `Decoder`, which should also allow a couple fewer branches.
  - Removes the `Decode::Ignore` wrapper enum, and instead ignoring
    1xx responses is handled directly in the response parsing code.

Ref #1563 

Closes #1395
2018-06-14 13:39:29 -07:00
Sean McArthur
15188b7c7f feat(client): implement Clone for Destination 2018-06-04 11:35:38 -07:00
Sean McArthur
19f90242f8 feat(body): remove Body::is_empty()
BREAKING CHANGE: `Body::is_empty()` is gone. Replace with
  `Body::is_end_stream()`, from the `Payload` trait.
2018-05-30 13:22:37 -07:00