A `From<StatusCode> for u16` has existed, but the docs cannot show it.
It also is slightly more annoying to use if type inference can't figure
the types out. This includes an explicit method to get a `u16`.
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