208 Commits

Author SHA1 Message Date
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
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
Steven Fackler
6164e76405 feat(server): Handle 100-continue
cc #838
2017-06-25 13:14:32 -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
0473d90a85 fix(server): fix broken keep-alive in Server
Closes #1134
2017-04-12 18:31:50 -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
Alex Crichton
f45e9c8e4f refactor(server): expose Http that implements ServerProto
The main changes are:

* The entry point is how `Http`, the implementation of `ServerProto`.
  This type has a `new` constructor as well as builder methods to
  configure it.

* A high-level entry point of `Http::bind` was added which returns a
  `Server`. Binding a protocol to a port requires a socket address
  (where to bind) as well as the instance of `NewService`. Internally
  this creates a core and a TCP listener.

* The returned `Server` has a few methods to learn about itself, e.g.
  `local_addr` and `handle`, but mainly has two methods: `run` and
  `run_until`.

* The `Server::run` entry point will execute a server infinitely, never
  having it exit.

* The `Server::run_until` method is intended as a graceful shutdown
  mechanism. When the provided future resolves the server stops
  accepting connections immediately and then waits for a fixed period of
  time for all active connections to get torn down, after which the
  whole server is torn down anyway.

* Finally a `Http::bind_connection` method exists as a low-level entry
  point to spawning a server connection. This is used by `Server::run`
  as is intended for external use in other event loops if necessary or
  otherwise low-level needs.

BREAKING CHANGE: `Server` is no longer the pimary entry point. Instead,
  an `Http` type is created  and then either `bind` to receiver a `Server`,
  or it can be passed to other Tokio things.
2017-01-18 14:09:20 -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