Commit Graph

1996 Commits

Author SHA1 Message Date
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
Sean McArthur
0cfa7231b2 test(client): update from deprecated export of ConnectFuture 2018-09-27 15:29:57 -07:00
Sean McArthur
5bfc110538 refactor(client): improve connect module structure 2018-09-27 14:50:11 -07:00
Sean McArthur
1370a6f8f0 fix(server): use provided executor if fallback to HTTP2 2018-09-18 15:20:28 -07:00
Sean McArthur
8f91747466 v0.12.10 2018-09-14 17:43:30 -07:00
Sean McArthur
2f19578162 test(http1): add test for when headers contain HTABs 2018-09-14 17:42:10 -07:00
Bastien Orivel
ca5e520e7a fix(http1): fix title-case option when header names have symbols
Don't eat the first character in a header name if it's not a letter. Same thing after a `-`
2018-09-14 17:30:50 -07:00
Sean McArthur
b05891906e chore(travis): set minimum rust version to 1.26 because of dependencies 2018-08-29 18:24:27 -07:00
Sean McArthur
57556e6329 v0.12.9 2018-08-28 17:31:21 -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
Alexis Mousset
e3dc6c5511 docs(examples): Fix typo in client_json example comment
Fixes typo on comment about error types in client_json example.
2018-08-27 10:23:16 -07:00
Sean McArthur
abe8ddd637 chore(travis): set minimum rust version to 1.25 because of dependencies 2018-08-27 10:21:25 -07:00
Sean McArthur
168c7d2155 feat(server): add Server::with_graceful_shutdown method
This adds a "combinator" method to `Server`, which accepts a user's
future to "select" on. All connections received by the `Server` will
be tracked, and if the user's future finishes, graceful shutdown will
begin.

- The listener will be closed immediately.
- The currently active connections will all be notified to start a
  graceful shutdown. For HTTP/1, that means finishing the existing
  response and using `connection: clone`. For HTTP/2, the graceful
  `GOAWAY` process is started.
- Once all active connections have terminated, the graceful future
  will return.

Closes #1575
2018-08-23 11:30:44 -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
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
bdbaa85f41 v0.12.8 2018-08-10 14:42:27 -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
b459adb43a feat(server): add Builder::http1_keepalive method 2018-08-10 13:08:08 -07:00
Yusuke Sasaki
1e8cd5aaa6 chore(*): enable #[deny(warnings)] at only testing 2018-08-10 10:40:40 -07:00
Sean McArthur
0ea3b836f9 refactor(server): remove double nested listen errors in from_tcp 2018-08-08 11:23:37 -07:00
Yoshua Wuyts
bb4c5e24c8 feat(server): add Server::from_tcp constructor
Adds a constructor to build a `Server` from an `std::net::TcpListener`.

Closes #1602
2018-08-08 11:13:07 -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
97f4243a59 refactor(headers): remove usage of deprecated ascii trait 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