Commit Graph

293 Commits

Author SHA1 Message Date
Sean McArthur
88f01793be fix(client): send an Error::Cancel if a queued request is dropped
Adds `Error::Cancel` variant.
2018-02-07 13:12:33 -08:00
Sean McArthur
b0aa649725 feat(client): add http1_writev configuration option
Setting this to false will force HTTP/1 connections to always flatten
all buffers (headers and body) before writing to the transport. The
default is true.
2018-02-06 14:53:21 -08:00
Sean McArthur
648548cfa3 test(client): add benchmarks for new cancelable queue 2018-02-06 12:31:31 -08:00
Sean McArthur
b7293ca6ff refactor(client): clean up pool Checkout::poll function 2018-02-05 11:53:17 -08:00
Sean McArthur
265ad67c86 fix(client): more reliably detect closed pooled connections (#1434) 2018-02-05 09:56:29 -08:00
Sean McArthur
b14de9eb34 refactor(client): fix up should_close sentinel value 2018-01-30 17:09:16 -08:00
Sean McArthur
84f3076438 perf(client): don't make a copy of Headers each Request 2018-01-30 14:58:51 -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
c93b082c85 refactor(compat): use pub(super) to remove compat_impl modules 2018-01-22 10:42:41 -08:00
Sean McArthur
c89019eb10 feat(client): add executor method when configuring a Client
This allows using a future `Executor` other than a `Handle` to execute
the background (connection) tasks needed for sending requests and
responses.

This also deprecates `Client::handle()`, since the executor may not be
a `Handle`.
2018-01-19 16:58:57 -08:00
Sean McArthur
2fe90f2564 fix(client): change connection errors to debug log level
Closes #1412
2018-01-09 17:46:35 -08:00
Sean McArthur
6ade21aa7f feat(server): change default dispatcher
- Deprecates the `no_proto` configuration on `Server`. It is always
  enabled.
- Deprecates all pieces related to tokio-proto.
- Makes the tokio-proto crate optional, and the `server-proto` feature
  can be used to completely remove the dependency. It is enabled by
  default.
2017-12-28 19:15:57 -08:00
Sean McArthur
0892cb2777 feat(client): replace default dispatcher 2017-12-28 17:18:42 -08:00
Sean McArthur
139dc7ab2b fix(client): properly close idle connections after timeout
Additionally fixes if there were idle connections when a `Client` is
dropped.

Only fixes with the no-proto dispatcher, as changing internals for the
tokio-proto dispatcher would be much harder, and it will replace it very
soon.

Closes #1397
2017-12-13 16:29:25 -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
Sam Rijs
b1785c662b feat(client): skip dns resolution when host is a valid ip addr (#1372) 2017-11-13 15:00:34 -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
b2ab42e607 chore(client): remove unused old test 2017-10-27 12:52:38 -07:00
Sean McArthur
f7532b71d1 feat(lib): add support to disable tokio-proto internals
For now, this adds `client::Config::no_proto`, `server::Http::no_proto`,
and `server::Server::no_proto` to skip tokio-proto implementations, and
use an internal dispatch system instead.

`Http::no_proto` is similar to `Http::bind_connection`, but returns a
`Connection` that is a `Future` to drive HTTP with the provided service.
Any errors prior to parsing a request, and after delivering a response
(but before flush the response body) will be returned from this future.

See #1342 for more.
2017-10-27 00:02:07 -07:00
Sam Rijs
ed497bf5e6 feat(client): allow custom executors for HttpConnector 2017-10-18 15:56:33 +11:00
brogowski
e0de55daa2 feat(client): add names to DNS threads 2017-10-03 20:02:41 +00:00
Sean McArthur
9c80fdbb9e refactor(lib): rename http_types to http 2017-09-29 18:12:55 -07:00
Sean McArthur
0fbc215f4b fix(client): fix panic in Pool
Closes #1339
2017-09-28 21:44:41 -07:00
Sean McArthur
57f86d42f2 refactor(lib): fix compat layer after rename to proto 2017-09-28 21:43:44 -07:00
Sean McArthur
5027435791 refactor(lib): rename internal http module to proto 2017-09-28 18:28:44 -07:00
Sam Rijs
0c7d375ba3 feat(lib): implement compatibility with http crate 2017-09-22 12:07:57 -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
41c47241cd fix(client): return Version errors if unsupported
If a `Request`'s version is `Http09`, `H2`, or `H2c`, `client.request`
will return a `hyper::Error::Version`, and a message is logged at
`error!` level.

Closes #1283
2017-09-16 17:20:31 -07:00
Sean McArthur
7081c4498e fix(uri): fix Uri parsing of IPv6 and userinfo
Closes #1269
2017-07-26 16:32:56 -07:00
Sean McArthur
6f1a87097e style(lib): add must_use attributes to futures and streams 2017-07-24 10:11:29 -07:00
wangcong
d7edc19af2 style(client): rename req to resp 2017-07-03 09:00:11 -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
Corey Farwell
1059eb349a style(lib): address clippy code style warnings
* Remove unnecessary return statements.

* Combine identical `match` arms.

* Collapse nested conditional.

* Use `assert_ne` where applicable.

* Lifetime elision.
2017-06-12 20:16:20 -07:00
David Ross
5391d02c10 fix(client): remove config requirement for Connect
Remove requirement when calling client::Config::connector() that the connector implements Connect.

Removing this requirement allows users to set the connector back to UseDefaultConnector. Previously,
this was not possible.
2017-06-01 23:38:01 -07:00
Sean McArthur
6655134583 refactor(client): make HttpConnector lazy 2017-05-08 11:51:20 -07:00
Sean McArthur
e6b588b81d docs(client): remove outdated reference to Handler trait 2017-05-08 11:50:54 -07:00
Nick Gonzales
864d3e27a4 refactor(http): merge Request and Response from server and client
Request and Response are now visible from:
- hyper::{Request, Response}
- hyper::server::{Request, Response}
- hyper::client::{Request, Response}
They truly exist in the http module, but are re-exported to reduce the number of breaking changes.

request::new and response::new were renamed to ::from_wire to reduce confusion with Request::new
and Response::new. See issue #1126

Request now has an optional Body, because not all requests have bodies.
Use body_ref() to determine if a body exists.
Use body() to take the body, or construct one if no body exists.

Closes #1155

BREAKING CHANGE: Response::body() now consumes the response
2017-05-01 14:22:07 -06:00
Sean McArthur
1c34a05a85 feat(client): add HttpConnector.enforce_http
This will make the `HttpConnector` require the `scheme` to be `http`,
and return an error otherwise. This value is enabled by default, so any
requests to URLs that aren't of scheme `http` will now see an error
message stating the failure.

When constructing a connector that wraps an `HttpConnector`, this
enforcement can be disabled to allow connecting over TCP easily even
when the scheme is not `http`. To do, call
`connector.enforce_http(false)`.
2017-04-24 12:08:15 -07:00
James Kay
4e26646aa7 feat(client): add an accessor for the request body
Allow users to access the body of the request.
Useful when one wants to modify the request based
on the data in the body, e.g. to add checksum headers.
2017-04-20 12:17:55 +01:00
Sean McArthur
d63b7de44f feat(client): Response.status() now returns a StatusCode
Previously, it would return `&StatusCode`. Returning a reference was
actually bigger than the enum itself, and prevented using `Into` on the
return result directly.

BREAKING CHANGE: If you were explicitly checking the status, such as
  with an equality comparison, you will need to use the value instead of a
  reference.
2017-03-31 15:13:55 -07:00
Daiki Mizukami
9101817b0f feat(client): add Client::handle 2017-03-27 08:06:07 +09:00
Sean McArthur
4f69788f5d fix(client): get default port for https with Uri 2017-03-21 14:44:04 -07:00
Sean McArthur
4fb7e6ebc6 feat(lib): remove extern Url type usage
BREAKING CHANGE: The `Url` type is no longer used. Any instance in the
  `Client` API has had it replaced with `hyper::Uri`.

  This also means `Error::Uri` has changed types to
  `hyper::error::UriError`.

  The type `hyper::header::parsing::HTTP_VALUE` has been made private,
  as an implementation detail. The function `http_percent_encoding`
  should be used instead.
2017-03-21 11:03:57 -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
e871411627 feat(client): add Request.set_proxy for HTTP proxy requests
Closes #1056
2017-03-07 12:16:44 -08:00
Sean McArthur
1b1311a7d3 feat(http): allow specifying custom body streams 2017-02-16 15:06:55 -08:00
Guillaume Gomez
524f65a9a3 perf(header): Make Uri use MemSlice internally 2017-02-09 11:45:55 -08:00
Julian Tescher
2fa414fb5f fix(lib): Fixed typos in multiple modules
BREAKING CHANGE: The `Preference` header had a typo in a variant and it's string representation,
  change `Preference::HandlingLeniant` to `Preference::HandlingLenient`.
2017-02-07 11:04:42 -08:00