bugfix: Don't re-pool streams on drop.
We only want streams in the pool that are ready for the next request, and don't have any remaining bytes of the previous request. That's the case when we return a stream due to EOF on the underlying `Read`. However, there was also an `impl Drop` that returned the stream to the pool on drop of a PoolReturnRead. That resulted in a bug: If a user called `response.into_reader()`, but did not read the entire body, a dirty stream would be returned to the pool. The next time a request was made to the same host, that stream would be reused, and instead of reading off "HTTP/1.1 200 OK", ureq would read a remnant of the previous request, resulting in a BadStatus error.
This commit is contained in:
committed by
Martin Algesten
parent
b01be808c5
commit
786047629a
@@ -415,9 +415,3 @@ impl<R: Read + Sized + Into<Stream>> Read for PoolReturnRead<R> {
|
||||
Ok(amount)
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: Read + Sized + Into<Stream>> Drop for PoolReturnRead<R> {
|
||||
fn drop(&mut self) {
|
||||
self.return_connection();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user