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.
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)`.
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
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.
- 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
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`.
- 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.
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
- 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`.
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.
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
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
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.