diff --git a/examples/client.rs b/examples/client.rs index b2d32667c0..ba638c66dd 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -7,6 +7,8 @@ use std::env; use std::io; use hyper::Client; +use hyper::header::Connection; +use hyper::header::ConnectionOption::Close; fn main() { env_logger::init().unwrap(); @@ -21,10 +23,9 @@ fn main() { let mut client = Client::new(); - let mut res = match client.get(&*url).send() { - Ok(res) => res, - Err(err) => panic!("Failed to connect: {:?}", err) - }; + let mut res = client.get(&*url) + .header(Connection(vec![Close])) + .send().unwrap(); println!("Response: {}", res.status); println!("Headers:\n{}", res.headers); diff --git a/src/client/request.rs b/src/client/request.rs index 33fe724d65..b8dfa4e369 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -1,7 +1,6 @@ //! Client Requests use std::marker::PhantomData; use std::io::{self, Write, BufWriter}; -use std::net::Shutdown; use url::Url; @@ -154,10 +153,7 @@ impl Request { /// /// Consumes the Request. pub fn send(self) -> ::Result { - let mut raw = try!(self.body.end()).into_inner().unwrap(); // end() already flushes - if !http::should_keep_alive(self.version, &self.headers) { - try!(raw.close(Shutdown::Write)); - } + let raw = try!(self.body.end()).into_inner().unwrap(); // end() already flushes Response::new(raw) } }