perf(client): don't make a copy of Headers each Request

This commit is contained in:
Sean McArthur
2018-01-30 14:58:51 -08:00
parent bf5eb5e0a0
commit 84f3076438
3 changed files with 21 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ use http;
use tokio::reactor::Handle;
pub use tokio_service::Service;
use header::{Headers, Host};
use header::{Host};
use proto;
use proto::request;
use method::Method;
@@ -180,12 +180,14 @@ where C: Connect,
))));
}
};
let host = Host::new(domain.host().expect("authority implies host").to_owned(), domain.port());
let (mut head, body) = request::split(req);
let mut headers = Headers::new();
headers.set(host);
headers.extend(head.headers.iter());
head.headers = headers;
if !head.headers.has::<Host>() {
let host = Host::new(
domain.host().expect("authority implies host").to_owned(),
domain.port(),
);
head.headers.set_pos(0, host);
}
use futures::Sink;
use futures::sync::{mpsc, oneshot};