Instead, you can use an instance of a NetworkConnector with
`Request::with_connector`. This allows overloading of the NetworkStream
constructors, so that it is easy to modify how an `HttpStream` is
created, while still relying on the rest of the stream implementation.
BREAKING CHANGE
rfc2616 does not specify the maximum length of *Reason Phrase* so it's
a good practice to handle even unreasonably long input.
16 char. buffer is not enough to correctly handle even the common `304
Moved Permanently`. Increase buffer size to more realistic 32. Also, up
to 128 more characters will be read and ignored, providing even greater
versatility without increasing memory usage.
Issue #163
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]
This test case does not attempt to test all the methods exhaustively,
but it does at least test all the methods in the APIs. There's also a
check to make sure that Method can be used as part of a hash-table key.
- Rename read_until_space() to read_token_until_space()
- Check if the byte is part of the token in read_token_until_space()
- Return HttpMethodError if the token is empty
- Remove the unnecessary is_valid_method() function
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]