Commit Graph

72 Commits

Author SHA1 Message Date
Sean McArthur
3cd48b45fb feat(lib): replace types with those from http crate
BREAKING CHANGE: `Method`, `Request`, `Response`, `StatusCode`,
  `Version`, and `Uri` have been replaced with types from the `http`
  crate. The `hyper::header` module is gone for now.

  Removed `Client::get`, since it needed to construct a `Request<B>`
  with an empty body. Just use `Client::request` instead.

  Removed `compat` cargo feature, and `compat` related API.
2018-03-19 11:43:47 -07:00
Sean McArthur
91b9700862 refactor(client): only spawn pooled in executor if not ready when response recieved 2018-03-13 18:46:52 -07:00
Sean McArthur
d58aa73246 feat(server): add upgrade support to lower-level Connection API (#1459)
Closes #1323
2018-03-09 10:05:27 -08:00
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
9990e273f6 test(server): fix streaming_body incorrect test 2018-03-01 14:13:02 -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
68377ede70 perf(http): utilize writev when possible
By using `AsyncWrite::write_buf`, we can avoid some copies in some
cases. This especially helps throughput for chunked encoding.
2018-01-25 14:02:11 -08:00
Sean McArthur
4de0de73be test(benches): fix deprecated futures usage in benches 2018-01-23 16:34:16 -08:00
Sean McArthur
d22deb6572 feat(server): add Http::max_buf_size() option
The internal connection's read and write bufs will be restricted from
growing bigger than the configured `max_buf_size`.

Closes #1368
2018-01-23 16:09:28 -08:00
Sean McArthur
7cb72d2019 fix(server): send 400 responses on parse errors before closing connection 2018-01-23 15:31:26 -08:00
Sean McArthur
44c34ce9ad fix(server): error if Response code is 1xx
Returning a Response from a Service with a 1xx StatusCode is not
currently supported in hyper. It has always resulted in broken
semantics. This patch simply errors better.

- A Response with 1xx status is converted into a 500 response with no body.
- An error is returned from the `server::Connection` to alert about the
  bad response.
2018-01-23 13:02:56 -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
36e66a5054 fix(lib): properly handle HTTP/1.0 remotes
- Downgrades internal semantics to HTTP/1.0 if peer sends a message with
  1.0 version.
- If downgraded, chunked writers become EOF writers, with the connection
  closing once the writing is complete.
- When downgraded, if keep-alive was wanted, the `Connection: keep-alive`
  header is added.

Closes #1304
2018-01-22 10:08:27 -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
7a48d0e8b4 fix(lib): properly handle body streaming errors 2018-01-11 13:58:16 -08:00
Sean McArthur
7888451408 refactor(proto): return Error::Incomplete instead of UnexpectedEof 2018-01-11 11:45:28 -08:00
Sean McArthur
fa7f4377c1 fix(server): add remote_addr back to Request when using Http::bind
The `Request::remote_addr()` method has been deprecated.

Closes #1410
2018-01-08 10:04:01 -08:00
Sean McArthur
34f0dba6dc chore(log): update to log 0.4 2018-01-04 14:50:18 -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
bfb0f84d37 fix(client): fix panic when request body is empty string 2017-12-26 13:07:39 -08:00
Sean McArthur
5d5045d698 chore(windows): poll core again to drop window socket 2017-12-18 16:53:45 -08:00
Sean McArthur
9af18f3024 chore(tests): fix syntax error in server tests 2017-12-15 12:41:26 -08:00
Sean McArthur
5d05b284d8 chore(windows): add test for keep-alive dropped in failing test 2017-12-15 12:18:44 -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
be7ca0415d test(server): try to fix windows keep-alive test 2017-12-13 16:47:07 -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
eb9590e3da feat(server): Allow keep alive to be turned off for a connection (#1390)
Closes #1365
2017-12-04 10:14:20 -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
8bf7964875 fix(server): GET requests with no body have None instead of Empty
Closes #1373
2017-11-14 11:52:29 -08:00
Sean McArthur
39cf6ef7d2 feat(server): add server::Serve that can use a shared Handle
- Adds `Http::serve_addr_handle` which will bind to an address with a
  provided `Handle`, and return a `Serve`.
- Adds `server::Serve` which is a `Stream` of incoming `Connection`s
  being bound by a `NewService`.
- Renames `Http::no_proto` to `Http::serve_connection`.
2017-11-06 18:59:15 -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
32c4efb86e test(server): fix flaky pipeline disabled test 2017-09-25 01:08:20 -07:00
Sean McArthur
dd54f20b55 feat(server): add experimental pipeline flush aggregation option to Http
By enabling `Http::pipeline`, the connection will aggregate response
writes to try to improve sending more responses in a single syscall.
2017-09-22 15:39:33 -07:00
Sean McArthur
21de6b6cbf tests(client): improve panic message when client tests fail 2017-09-11 17:50:12 -07:00
Sean McArthur
cb9aff3c52 chore(tests): fix test for deprecated Future::boxed 2017-08-24 15:05:42 -07:00