Commit Graph

42 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
bfcdbd9f86 fix(client): return error if Request has CONNECT method
The higher-level `Client` has never supported `CONNECT` requests,
but it used to send them, and then handle the responses incorrectly.
Now, it will return an error immediately instead of misbehaving.
2018-03-06 10:48:59 -08:00
Sean McArthur
33a385c6b6 feat(client): add Config::set_host option
If set to false, the `Client` will no longer automatically set the
`Host` header if absent.
2018-03-06 10:37:40 -08:00
Sean McArthur
3e87eb48b1 tests(client): fix client test warnings 2018-03-05 15:37:50 -08:00
Sean McArthur
994bcd193c tests(client): make retryable request tests more reliable 2018-03-05 15:05:24 -08:00
Sean McArthur
13741f5145 fix(client): never call connect if idle connection is available
The HttpConnector's connect future was lazy, but if any custom connector
did not use a lazy future, then a connect would always be started, even
if an idle connection was available.
2018-02-28 14:18:37 -08:00
Sean McArthur
77adab4ebf fix(client): prevent empty bodies sending transfer-encoding for GET, HEAD 2018-02-16 15:22:06 -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
dc619a8fa0 fix(client): detect connection closes as pool tries to use
Currently, if the remote closes the connection at the same time that the
pool selects it to use for a new request, the connection may actually
hang. This fix will now more allow the keep-alive read to check the
socket even when the `Conn` think it's busy.

If the connection was closed before the request write happened, returns
back an `Error::Cancel`, letting the user know they could safely retry
it.

Closes #1439
2018-02-12 18:16:21 -08:00
Sean McArthur
3a124462c6 test(h1): fix flaky streaming test 2018-02-06 13:25:10 -08:00
Sean McArthur
731096947d fix(h1): fix hung streaming bodies over HTTPS 2018-02-05 16:33:23 -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
227742221f fix(client): error on unsupport 101 responses, ignore other 1xx codes 2018-01-23 11:33:24 -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
7888451408 refactor(proto): return Error::Incomplete instead of UnexpectedEof 2018-01-11 11:45:28 -08:00
Sean McArthur
34f0dba6dc chore(log): update to log 0.4 2018-01-04 14:50:18 -08:00
Sean McArthur
0892cb2777 feat(client): replace default dispatcher 2017-12-28 17:18:42 -08:00
Sean McArthur
bfb0f84d37 fix(client): fix panic when request body is empty string 2017-12-26 13:07:39 -08:00
Sean McArthur
ef4008121e fix(client): close connections when Response Future or Body is dropped
Closes #1397
2017-12-14 13:57:31 -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
95e0164e8f fix(client): return error instead of unmatched response when idle 2017-12-06 16:06:13 -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
7c4b814e6b fix(client): don't read extra bytes on idle connections 2017-10-27 11:28:20 -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
Julian Tescher
5700ad79a3 docs(changelog,header,proto,client): Fix small typos 2017-10-21 20:07:56 -07:00
Sean McArthur
21de6b6cbf tests(client): improve panic message when client tests fail 2017-09-11 17:50:12 -07:00
Sean McArthur
673e5cb1a3 fix(server): improve detection of when a Response can have a body
By knowing if the incoming Request was a HEAD, or checking for 204 or
304 status codes, the server will do a better job of either adding
or removing `Content-Length` and `Transfer-Encoding` headers.

Closes #1257
2017-07-13 12:19:53 -07:00
Sean McArthur
f05a58a1b2 chore(travis): set minimum rust version 2017-04-10 15:09:54 -07: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
wangcong
34509ef51a test(client): replace deprecated Sender.completer with send 2017-03-14 10:11:22 -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
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
Sean McArthur
39a53fcd33 Merge pull request #1014 from hyperium/next-uri
feat(uri): redesign RequestUri type into Uri
2017-01-17 17:44:18 -08:00
Sean McArthur
49e281d086 test(client): disable flaky disconnect test 2017-01-17 17:25:55 -08:00
Guillaume Gomez
9036443e6b feat(uri): redesign RequestUri type into Uri
Closes #1000

BREAKING CHANGE: The name of `RequestUri` has changed to `Uri`. It is no
  longer an `enum`, but an opaque struct with getter methods.
2017-01-17 16:46:24 -08:00
Sean McArthur
e4232dd0d8 test(client): sleep disconnect test to reduce flakiness
Closes #1003
2017-01-16 12:58:06 -08: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
2904668105 feat(client): implement connection pooling for Client
Closes #830
Closes #848
2016-07-08 10:07:02 -07:00
Sean McArthur
c856de0428 feat(client): add method to end a chunked body for a Request
Closes #831
2016-06-17 07:01:42 -07:00
Sean McArthur
2d9aea8db0 fix(client): send query parameters in Requests 2016-05-23 11:19:43 -07:00
Sean McArthur
d35992d019 feat(lib): switch to non-blocking (asynchronous) IO
BREAKING CHANGE: This breaks a lot of the Client and Server APIs.
  Check the documentation for how Handlers can be used for asynchronous
  events.
2016-05-16 09:51:18 -07:00