Add req field to Unit and remove cloned parts from request (#158)

Instead of cloning most of `Request`'s fields individually when
creating a `Unit`, this PR switches to just cloning `Request` and
stuffing it in `Unit`, and changes references to `unit.[field]` to
`unit.req.[field]` where appropriate.

Fixes #155
This commit is contained in:
Daniel Rivas
2020-09-26 18:22:10 +01:00
committed by GitHub
parent be9e3ca936
commit 8bba07a9af
4 changed files with 31 additions and 53 deletions

View File

@@ -394,7 +394,7 @@ impl<R: Read + Sized + Into<Stream>> PoolReturnRead<R> {
fn return_connection(&mut self) {
// guard we only do this once.
if let (Some(unit), Some(reader)) = (self.unit.take(), self.reader.take()) {
let state = &mut unit.agent.lock().unwrap();
let state = &mut unit.req.agent.lock().unwrap();
// bring back stream here to either go into pool or dealloc
let stream = reader.into();
if !stream.is_poolable() {
@@ -402,7 +402,7 @@ impl<R: Read + Sized + Into<Stream>> PoolReturnRead<R> {
return;
}
// insert back into pool
let key = PoolKey::new(&unit.url, &unit.proxy);
let key = PoolKey::new(&unit.url, &unit.req.proxy);
state.pool().add(key, stream);
}
}