Previously, iter() returned (&str, HeaderView), which wasn't too useful
other than to write out to a stream. Checking for a certain header is
painful since header names are case-insensitive, but &str isn't. And
once found, you still couldn't do anything with a HeaderView other
format it.
Now, iter() returns a HeaderView, with methods is(), name(), and
value(). You can do `view.is::<ContentType>()` to check what header it
is. And you get the typed value out by calling
`view.value::<ContentType>()`, which will return an
`Option<ContentType>`, similar to `headers.get()`.
Headers also now implement Extend and FromIterator, so it's easier to
build new Headers objects by filtering out a few headers.
Because this changes .iter() to return HeaderView instead of a tuple,
this is a:
[breaking-change]
Internals have been shuffled around such that Request and Reponse are
now given only a mutable reference to the stream, instead of being
allowed to consume it. This allows the server to re-use the streams if
keep-alive is true.
A task pool is used, and the number of the threads can currently be
adjusted by using the `listen_threads()` method on Server.
[breaking-change]
This adds a dependency on the time crate found in rust-lang/time
and fixes a field rename from tm_gmtoff to tm_utcoff.
add time dependency
tm_gmtoff has been renamed to tm_utcoff
An Authorization header contains a Scheme. If you have no real scheme,
you can use String as your scheme (Authorization<String>).
This includes the `Basic` scheme built-in.
Header contains all of the trait-object unsafe methods
including the name of the header and parsing. HeaderFormat
contains fmt_header, which is the only trait-object safe
method.
Internal representation was changed from an enum back to a Struct again.
The raw representation *has* to stick around, even if parsed as a proper
typed header. The reason is that internally, hyper will access some
headers to know which parts of the http protocol to follow (such as if
the response has a length or is chunked). The raw value may still be
needed afterwards, such as for a DOM binding of
.getAllResponseHeaders().
Since the raw is kept around, the unsafety of get_raw is no longer true,
and so that is removed.
It's still more ergonomic to access the types, and safer as well, so
that is recommended when possible.