refactor(header): Host header internals made private

This allows us to improve the performance. For now, a Cow is used
internally, so clients can set the host to a static value and no longer
need copies.

Later, we can change it to also possibly have a MemSlice.

BREAKING CHANGE: The fields of the `Host` header are no longer
  available. Use the getter methods instead.
This commit is contained in:
Sean McArthur
2017-01-13 15:27:35 -08:00
parent 0167f57d65
commit cd9fd52207
4 changed files with 45 additions and 66 deletions

View File

@@ -123,10 +123,7 @@ impl<C: Connect> Service for Client<C> {
let (mut head, body) = request::split(req);
let mut headers = Headers::new();
headers.set(Host {
hostname: url.host_str().unwrap().to_owned(),
port: url.port().or(None),
});
headers.set(Host::new(url.host_str().unwrap().to_owned(), url.port()));
headers.extend(head.headers.iter());
head.subject.1 = RequestUri::AbsolutePath {
path: url.path().to_owned(),