feat(client): add a Connection Pool
This adds a connection pool to the Client that is used by default. It accepts any other NetworkConnector, and simply acts as a NetworkConnector itself. Other Pools can exist by simply providing a custom NetworkConnector. This Pool is only used by default if you also use the default connector, which is `HttpConnector`. If you wish to use the Pool with a custom connector, you'll need to create the Pool with your custom connector, and then pass that pool to the Client::with_connector. This also adds a method to `NetworkStream`, `close`, which can be used to know when the Stream should be put down, because a server requested that the connection close instead of be kept alive. Closes #363 Closes #41
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| //! Client Responses | ||||
| use std::io::{self, Read}; | ||||
| use std::marker::PhantomData; | ||||
| use std::net::Shutdown; | ||||
|  | ||||
| use buffer::BufReader; | ||||
| use header; | ||||
| @@ -42,6 +43,10 @@ impl Response { | ||||
|         debug!("version={:?}, status={:?}", head.version, status); | ||||
|         debug!("headers={:?}", headers); | ||||
|  | ||||
|         if !http::should_keep_alive(head.version, &headers) { | ||||
|             try!(stream.get_mut().close(Shutdown::Write)); | ||||
|         } | ||||
|  | ||||
|         let body = if headers.has::<TransferEncoding>() { | ||||
|             match headers.get::<TransferEncoding>() { | ||||
|                 Some(&TransferEncoding(ref codings)) => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user