Commit Graph

1921 Commits

Author SHA1 Message Date
Sean McArthur
fd25129dc0 perf(http1): implement an adaptive read buffer strategy
The default read strategy for HTTP/1 connections is now adaptive. It
increases or decreases the size of the read buffer depending on the
number of bytes that are received in a `read` call. If a transport
continuously fills the read buffer, it will continue to grow (up to the
`max_buf_size`), allowing for reading faster. If the transport
consistently only fills a portion of the read buffer, it will be shrunk.

This doesn't provide much benefit to small requests/responses, but
benchmarks show it to be a noticeable improvement to throughput when
streaming larger bodies.

Closes #1708
2018-11-28 12:54:17 -08:00
Johannes Weissmann
a6fff13a39 feat(server): add tcp_sleep_on_accept_errors builder method
This method allows to set the value of the `sleep_on_errors` option for
accepted connections using the builder.

Closes #1713
2018-11-27 16:25:15 -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
c35bdca8fa chore(dependencies): update http to 0.1.14 for Uri::port_part 2018-11-27 11:55:02 -08:00
Jeff Labonte
69368f433f refactor(client): update from deprecated Uri::port to port_part (#1722) 2018-11-26 10:06:40 -08:00
Sean McArthur
7fb6e3a3ff v0.12.16 2018-11-21 16:43:12 -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
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
92a8aba610 v0.12.15 2018-11-20 12:55:08 -08:00
Sean McArthur
95446cc338 feat(client): add client::conn::Builder::executor method 2018-11-16 16:32:09 -08:00
Sean McArthur
30870029b9 feat(server): change NewService to MakeService with connection context
This adjusts the way `Service`s are created for a `hyper::Server`. The
`MakeService` trait allows receiving an argument when creating a
`Service`. The implementation for `hyper::Server` expects to pass a
reference to the accepted transport (so, `&Incoming::Item`). The user
can inspect the transport before making a `Service`.

In practice, this allows for things like getting the remote socket
address, or the TLS certification, or similar.

To prevent a breaking change, there is a blanket implementation of
`MakeService` for any `NewService`. Besides implementing `MakeService`
directly, there is also added `hyper::service::make_service_fn`.

Closes #1650
2018-11-16 13:18:09 -08:00
Sean McArthur
1158bd20b3 v0.12.14 2018-11-07 11:01: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
bf188b28fe test(drain): add tests for futures drain utility 2018-10-26 13:59:58 -07:00
Sean McArthur
3af6aa80af v0.12.13 2018-10-26 13:04:03 -07:00
Sean McArthur
5ca2905c84 test(server): server test cleanup 2018-10-26 12:50:27 -07:00
Sean McArthur
576addd531 test(benches): don't concat chunks, just drop them 2018-10-25 17:22:01 -07:00
Sean McArthur
79f970c7ff test(benches): clean up end_to_end benchmark configuration 2018-10-25 17:15:06 -07:00
Sean McArthur
b20971cb4e perf(http2): less eager server polls since it hurts parallel flushing 2018-10-24 15:35:11 -07:00
Sean McArthur
6005827c3e refactor(http2): set content-length even when full_data is available 2018-10-24 15:20:21 -07:00
Sean McArthur
94e02ac276 perf(http2): eagerly poll some futures in h2 dispatchers before allocating in executor 2018-10-24 15:04:30 -07:00
Sean McArthur
dcf0347151 test(benches): add http1 pipeline bench target 2018-10-23 16:01:16 -07:00
Sean McArthur
4843364b5a test(benches): uses current_thread runtime in server benchmarks 2018-10-23 15:38:06 -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
8bfe3c220c refactor(exec): fix unused warning when runtime feature is disabled 2018-10-16 15:53:55 -07:00
Sean McArthur
c5e807715a refactor(error): improve error message when tokio::spawn fails
Closes #1635
2018-10-16 15:14:20 -07:00
Sean McArthur
12bc4cb485 refactor(server): remove commented out where bounds 2018-10-16 14:46:44 -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
Sander Maijers
d55b5efb89 feat(http): reexport http crate 2018-10-16 14:05:01 -07:00
Sean McArthur
ced949cb6b feat(server): allow !Send Servers
Until this commit, servers have required that `Service` and their
`Future` to be `Send`, since the server needs to spawn some internal
tasks to an executor, and by default, that is `tokio::spawn`, which
could be spawning to a threadpool. This was true even if the user were
certain there was no threadpool involved, and was instead using a
different single-threaded runtime, like
`tokio::runtime::current_thread`.

This changes makes all the server pieces generic over an `E`, which is
essentially `Executor<PrivateTypes<Server::Future>>`. There's a new set
of internal traits, `H2Exec` and `NewSvcExec`, which allow for the type
signature to only show the generics that the user is providing. The
traits cannot be implemented explicitly, but there are blanket
implementations for `E: Executor<SpecificType>`. If the user provides
their own executor, it simply needs to have a generic `impl<F>
Executor<F> for MyExec`. That impl can have bounds deciding whether to
require `F: Send`. If the executor does require `Send`, and the
`Service` futures are `!Send`, there will be compiler errors.

To prevent a breaking change, all the types that gained the `E` generic
have a default type set, which is the original `tokio::spawn` executor.
2018-10-16 13:21:45 -07:00
Sean McArthur
00c96de0b9 v0.12.12 2018-10-16 10:22:02 -07:00
Simon Sapin
30a4f2376a fix(armv7): split record_header_indices loop to work around rustc/LLVM bug
rustc issue: https://github.com/rust-lang/rust/issues/55105

Steps to reproduce:

```
rustup target add armv7-linux-androideabi
RUSTFLAGS="-Ctarget-feature=+neon" cargo build --target armv7-linux-androideabi --release
```

Output without this change:

```
   Compiling hyper v0.12.11 (/home/simon/projects/servo-deps/hyper)
LLVM ERROR: ran out of registers during register allocation
error: Could not compile `hyper`.
```
2018-10-16 10:17:55 -07:00
Sean McArthur
66a857d801 fix(server): log and ignore connection errors on newly accepted sockets 2018-10-09 16:04:31 -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
3e12bccac0 refactor(body): use fmt::Debug of Bytes for Chunk 2018-10-08 10:22:52 -07:00
Ahmed Charles
9fa721df9e docs(examples): add proxy example 2018-10-02 10:07:31 -07:00
Sean McArthur
5c3415d704 v0.12.11 2018-09-28 13:04:52 -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