Commit Graph

35 Commits

Author SHA1 Message Date
Sean McArthur
1207c2b624 feat(client): introduce lower-level Connection API
Closes #1449
2018-03-07 14:26:52 -08:00
Sean McArthur
4351ed1d13 chore(client): fix unused_mut warning in 1.18 2018-02-28 16:45:43 -08:00
Sean McArthur
2fa0c845b5 fix(client): check conn is closed in expire interval 2018-02-28 15:16:01 -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
1223fc28ee wip 2018-02-28 13:58: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
Sean McArthur
b7293ca6ff refactor(client): clean up pool Checkout::poll function 2018-02-05 11:53:17 -08:00
Sean McArthur
44af273853 fix(client): check for dead connections in Pool
Closes #1429
2018-01-29 11:58:05 -08:00
Sean McArthur
7b5931122a feat(log): improve quality of debug level logs 2017-12-08 14:49:51 -08:00
Steven Fackler
d2aa5d862c fix(client): don't leak connections with no keep-alive
Closes #1383
2017-11-27 21:42:57 -08:00
Sean McArthur
b1765dd168 fix(client): drop in-use connections when they finish if Client is dropped 2017-10-30 15:20:56 -07:00
Sean McArthur
0fbc215f4b fix(client): fix panic in Pool
Closes #1339
2017-09-28 21:44:41 -07:00
Sean McArthur
5027435791 refactor(lib): rename internal http module to proto 2017-09-28 18:28:44 -07:00
Sean McArthur
3b91fc65b2 fix(client): cleanup dropped pending Checkouts from Pool
Closes #1315
2017-09-18 13:29:31 -07:00
Sean McArthur
4dfe0db0f4 perf(server): dont record Idle time when not needed 2017-06-25 11:51:43 -07:00
Sean McArthur
c166268c07 fix(client): prevent panicking when determine Expiration in pool
On some OSes, `Instant` would start counting 0 from the boot time. That
would mean that any `Instant::now() - dur` soon after boot had a higher
risk of overflowing. Now, the expiration is determined by calling
`idle.elapsed()`, and comparing durations.

Closes #1215
2017-06-13 09:21:56 -07:00
Alex Crichton
8554904dc9 refactor(lib): convert usage of tokio_core::io to tokio_io
This commit updates to the most recent versions (released today) of the various
Tokio libraries in use. Namely the `tokio_core::io` module has now been
deprecated in favor of an external `tokio-io` crate. This commit pulls in that
crate and uses the `AsyncRead + AsyncWrite` abstraction instead of `Io` from
tokio-core.

BREAKING CHANGE: Any external types that were using that had implemented `Io` will need to 
  implement `AsyncRead + AsyncWrite` from tokio_io.
2017-03-17 17:31:44 -07:00
Sean McArthur
2d2d5574a6 feat(lib): redesign API to use Futures and Tokio
There are many changes involved with this, but let's just talk about
user-facing changes.

- Creating a `Client` and `Server` now needs a Tokio `Core` event loop
to attach to.
- `Request` and `Response` both no longer implement the
`std::io::{Read,Write}` traits, but instead represent their bodies as a
`futures::Stream` of items, where each item is a `Chunk`.
- The `Client.request` method now takes a `Request`, instead of being
used as a builder, and returns a `Future` that resolves to `Response`.
- The `Handler` trait for servers is no more, and instead the Tokio
`Service` trait is used. This allows interoperability with generic
middleware.

BREAKING CHANGE: A big sweeping set of breaking changes.
2017-01-16 10:44:27 -08:00
Sean McArthur
42ebb768c3 chore(client): remove dead pool module 2016-06-01 18:28:33 -07:00
Sean McArthur
e51bafe2e4 fix(client): fix panic in Pool::connect
Closes #780
2016-05-05 10:45:16 -07:00
Sean McArthur
f36c6b255f feat(client): proper proxy and tunneling in Client
Closes #774
2016-05-02 12:33:49 -07:00
Sean McArthur
25010fc1fc feat(client): add Proxy support
This works by configuring proxy options on a `Client`, such as
`client.set_proxy("http", "127.0.0.1", "8018")`.

Closes #531
2016-04-25 15:49:57 -07:00
Sean McArthur
5fcc04a6cd perf(client): dont keep Pool mutex locked during getaddrinfo 2016-04-25 15:36:55 -07:00
Sean McArthur
fec6e3e873 feat(all): add socket timeouts
Methods added to `Client` and `Server` to control read and write
timeouts of the underlying socket.

Keep-Alive is re-enabled by default on the server, with a default
timeout of 5 seconds.

BREAKING CHANGE: This adds 2 required methods to the `NetworkStream`
  trait, `set_read_timeout` and `set_write_timeout`. Any local
  implementations will need to add them.
2015-11-24 10:58:58 -08:00
Sean McArthur
32e09a0429 fix(client): EofReader by nature means the connection is closed 2015-09-02 09:26:46 -07:00
Sean McArthur
75c7117020 fix(client): be resilient to invalid response bodies
When an Http11Message knows that the previous response should not
have included a body per RFC7230, and fails to parse the following
response, the bytes are shuffled along, checking for the start of the
next response.

Closes #640
2015-09-01 16:58:51 -07:00
Sean McArthur
7d1f154cb7 feat(net): add socket timeouts to Server and Client
While these methods are marked unstable in libstd, this is behind a
feature flag, `timeouts`. The Client and Server both have
`set_read_timeout` and `set_write_timeout` methods, that will affect all
connections with that entity.

BREAKING CHANGE: Any custom implementation of NetworkStream must now
  implement `set_read_timeout` and `set_write_timeout`, so those will
  break. Most users who only use the provided streams should work with
  no changes needed.

Closes #315
2015-07-27 09:57:59 -07:00
Sean McArthur
53bba6eb7f feat(ssl): redesign SSL usage
BREAKING CHANGE: Server::https was changed to allow any implementation
  of Ssl. Server in general was also changed. HttpConnector no longer
  uses SSL; using HttpsConnector instead.
2015-06-20 14:58:58 -07:00
Sean McArthur
e689f20376 fix(client): check for drained stream in Response::drop 2015-06-17 13:17:56 -07:00
Sean McArthur
1b318724a5 feat(net): remove mut requirement for NetworkConnector.connect()
BREAKING CHANGE: Any custom Connectors will need to change to &self in
  the connect method. Any Connectors that needed the mutablity need to
  figure out a synchronization strategy.

  Request::with_connector() takes a &NetworkConnector instead of &mut.
  Any uses of with_connector will need to change to passing &C.
2015-05-09 23:14:23 -07:00
Sean McArthur
7bc4e83ec2 Merge pull request #518 from mlalic/fix-client-ssl-verifier
fix(client): keep the underlying connector when setting an SSL verifier
2015-05-09 22:46:43 -07:00
Sean McArthur
a3637d5f73 refactor(all): adjust some logging 2015-05-09 22:18:05 -07:00
Marko Lalic
a5d632b6ea feat(net): add set_ssl_verifier method to NetworkConnector trait
The commit includes an implementation of the new trait method for all
existing trait impls.

BREAKING CHANGE: Adding a new required method to a public trait is a
breaking change.
2015-05-09 20:10:51 +02:00
Sean McArthur
972b3a388a feat(error): add Ssl variant to hyper::Error
The errors from openssl were previously boxed into a
Box<std::error::Error>, which lost some specifics and made it difficult
to match against. To solve this, an `Ssl` variant is added to the
`Error` enum of hyper, and is returned when openssl returns specific
errors.

Closes #483

BREAKING CHANGE: Adds a variant to `hyper::Error`, which may break any
exhaustive matches.
2015-05-05 18:25:19 -07:00
Sean McArthur
1e72a8ab3a feat(client): add a Connection Pool
This adds a connection pool to the Client that is used by default. It
accepts any other NetworkConnector, and simply acts as a
NetworkConnector itself. Other Pools can exist by simply providing a
custom NetworkConnector. This Pool is only used by default if you also
use the default connector, which is `HttpConnector`. If you wish to use
the Pool with a custom connector, you'll need to create the Pool with
your custom connector, and then pass that pool to the
Client::with_connector.

This also adds a method to `NetworkStream`, `close`, which can be used
to know when the Stream should be put down, because a server requested
that the connection close instead of be kept alive.

Closes #363
Closes #41
2015-04-29 12:58:28 -07:00