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
- Checks for that the `Transfer-Encoding` header has `chunked` as its
last encoding
- Makes `Transfer-Encoding` take priority over `Content-Length`
- Rejects requests that contain a `Content-Length` header, but is
invalid (or contains multiple with different values).
The Response body was previously inaccessible to application code. This
change allows applications that may wish to alter the Response based on
previous creation (or not) of the body to do so.
n.b. discussion in #1216 indicates this function may change in
0.12 or be removed in favour of some other api.
Closes#1216.
Update the docs for `Content-Length` and `Transfer-Encoding` to mention
that they are mutually exclusive, and that setting one will unset the
other, in accordance with RFC7230.
Also expand the docs for `Request::set_body` to say that chunked
encoding is used by default, and mention how to disable this feature.
This is a temporary function until the `TryFrom` trait stabilizes.
BREAKING CHANGE: Removes the undocumented `from_u16` function. Use
`StatusCode::try_from` instead.
Also makes the `status` module private. All imports of
`hyper::status::StatusCode` should be `hyper::StatusCode`.
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
The new mime crate has several benefits:
- Faster formatting
- Easier to use. Most common mime types are now just constants, like
`mime::TEXT_PLAIN`.
- Proper suffix support.
- Extensible without breaking backwards compatiblity. This means we can
always add new constants, but before we couldn't add new variants to the
enums.
- It's now impossible for a `Mime` to contain invalid tokens. Before,
with the `Ext(String)` variants, it was possible to create an illegal
mime.
Closes#738
BREAKING CHANGE: Most uses of `mime` will likely break. There is no more
`mime!` macro, nor a `Mime` constructor, nor `TopLevel` and `SubLevel`
enums.
Instead, in most cases, a constant exists that can now be used.
For less common mime types, they can be created by parsing a string.
The `RawStatus` types on the `Response` are now gone by default. To make
use of them, the `raw_status` feature must be enabled in `Cargo.toml`.
BREAKING CHANGE: To use `RawStatus`, you must enable the `raw_status`
crate feature.