-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Starting with commit 1e72a8a, Hyper errors out when trying to connect to some servers with ConnectionOption::Close header set. A common pattern seems to be that they're running nginx.
Here's a modified version of the example client:
extern crate hyper;
use std::io::Read;
use hyper::Client;
use hyper::header::Connection;
use hyper::header::ConnectionOption;
fn main() {
for url in vec![
"http://doc.rust-lang.org",
"http://www.linode.com",
"http://digitalocean.com",
"http://www.reddit.com",
"http://www.kernel.org",
"http://www.gooogle.com",
]
{
run(url);
}
}
fn run(url: &str) {
println!("Retrieve {}:", url);
let mut client = Client::new();
let result = client.get(url)
.header(Connection(vec![ConnectionOption::Close]))
.send();
match result {
Ok(mut res) => {
let mut body = String::new();
res.read_to_string(&mut body).unwrap();
println!("Success: {} bytes", body.len());
},
Err(_) => {
println!("Failed: {:?}", result);
},
}
println!("");
}
$ cargo update; cargo run
Updating registry `https://github.com/rust-lang/crates.io-index`
Compiling hyper v0.4.0 (file:///home/alec/test1)
Compiling test1 v0.1.0 (file:///home/alec/test1)
Running `target/debug/test1`
Retrieve http://doc.rust-lang.org:
Failed: Err(Io(Error { repr: Custom(Custom { kind: ConnectionAborted, error: StringError("Connection closed") }) }))
Retrieve http://www.linode.com:
Failed: Err(Io(Error { repr: Custom(Custom { kind: ConnectionAborted, error: StringError("Connection closed") }) }))
Retrieve http://digitalocean.com:
Failed: Err(Io(Error { repr: Custom(Custom { kind: ConnectionAborted, error: StringError("Connection closed") }) }))
Retrieve http://www.reddit.com:
Failed: Err(Io(Error { repr: Custom(Custom { kind: ConnectionAborted, error: StringError("Connection closed") }) }))
Retrieve http://www.kernel.org:
Failed: Err(Io(Error { repr: Custom(Custom { kind: ConnectionAborted, error: StringError("Connection closed") }) }))
Retrieve http://www.gooogle.com:
Success: 52184 bytes
$ cargo update; cargo run
Updating registry `https://github.com/rust-lang/crates.io-index`
Compiling hyper v0.3.15 (file:///home/alec/test1)
Compiling test1 v0.1.0 (file:///home/alec/test1)
Running `target/debug/test1`
Retrieve http://doc.rust-lang.org:
Success: 6414 bytes
Retrieve http://www.linode.com:
Success: 19898 bytes
Retrieve http://digitalocean.com:
Success: 19559 bytes
Retrieve http://www.reddit.com:
Success: 114095 bytes
Retrieve http://www.kernel.org:
Success: 19090 bytes
Retrieve http://www.gooogle.com:
Success: 52216 bytes
$ rustc --version
rustc 1.0.0-beta.4 (built 2015-05-09)
Metadata
Metadata
Assignees
Labels
No labels