Only call close() in the Response, which should already return a responding `Connection: close`. Closes #519
34 lines
683 B
Rust
34 lines
683 B
Rust
#![deny(warnings)]
|
|
extern crate hyper;
|
|
|
|
extern crate env_logger;
|
|
|
|
use std::env;
|
|
use std::io;
|
|
|
|
use hyper::Client;
|
|
use hyper::header::Connection;
|
|
use hyper::header::ConnectionOption::Close;
|
|
|
|
fn main() {
|
|
env_logger::init().unwrap();
|
|
|
|
let url = match env::args().nth(1) {
|
|
Some(url) => url,
|
|
None => {
|
|
println!("Usage: client <url>");
|
|
return;
|
|
}
|
|
};
|
|
|
|
let mut client = Client::new();
|
|
|
|
let mut res = client.get(&*url)
|
|
.header(Connection(vec![Close]))
|
|
.send().unwrap();
|
|
|
|
println!("Response: {}", res.status);
|
|
println!("Headers:\n{}", res.headers);
|
|
io::copy(&mut res, &mut io::stdout()).unwrap();
|
|
}
|