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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user