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.
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.
In the spirit of Postel's law, ignore invalid cookies rather than
completely discard the entire Cookie header, which is what the current
code does, and which will lead to confusion when dealing with headers
with invalid cookies injected by proxies and intermediate apps servers.
The `Cookie` header now has 'set' and `get` methods, to treat the list of
cookies as a map.
Closes#1145
BREAKING CHANGE: The `Cookie` header is no longer a wrapper over a
`Vec<String>`. It must be accessed via its `get` and `append` methods.
This makes the `u16` in `Quality` private, since it only has a valid
range of 0-1000, and can't be enforced in public. The `q` function now
allows both `f32`s and `u16`s to construct a `Quality`.
BREAKING CHANGE: Any use of `Quality(num)` should change to `q(num)`.
This removes the need for someone to use the `time` crate to create a
date compatible with HTTP headers. It now works with the `SystemTime`
type from the standard library.
BREAKING CHANGE: `HttpDate` no longer has public fields. Convert between
`HttpDate` and `SystemTime` as needed.
They can be re-added later, removing now prevents that fix from being a
breaking change.
BREAKING CHANGE: The `link_extensions` methods of the `Link` header are
removed until fixed.
The `header::Formatter` ensures that a formatted header is written to a
line, and allows for headers that require multiple lines. The only
header to specifically require this is `Set-Cookie`.
BREAKING CHANGE: The `fmt_header` method has changed to take a different
formatter. In most cases, if your header also implements
`fmt::Display`, you can just call `f.fmt_line(self)`.