-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple request always fails on Mac OS X #508
Comments
Can you re-run with |
Sure, doesn't look all that helpful though. I can tell you that it's the unwrap on send
|
Would you mind added env_logger (or similar) and collecting logs from On Tue, May 5, 2015, 10:25 PM Wesley Moore [email protected] wrote:
|
Sure, happy to help any way I can:
|
Hmm. Hyper is now calling shutdown because of the Connection: Close header. On Tue, May 5, 2015, 10:52 PM Wesley Moore [email protected] wrote:
|
@wezm If it's related to shutdown, this is the smallest case that would test it (I think...): use std::io::{Read, Write};
use std::net;
fn main() {
let mut stream = net::TcpStream::connect("rust-lang.org:80").unwrap();
stream.write_all(b"GET / HTTP/1.1\r\nHost: rust-lang.org\r\n\r\n").unwrap();
stream.shutdown(net::Shutdown::Write).unwrap();
let mut s = String::new();
stream.read_to_string(&mut s).unwrap();
println!("{}", s);
} |
The test case above works fine (does not panic) as posted. I tried adding a |
@wezm what if you comment out the |
@wezm if it works without the Connection close, try the tcp example with your own url (don't forget to edit the |
The hyper test case works when Connection close is removed. The TCP example when edited as follows also works, with and without the Connection close header. let mut stream = net::TcpStream::connect("files.wezm.net:80").unwrap();
stream.write_all(b"GET /testpodcast.xml HTTP/1.1\r\nHost: files.wezm.net\r\n\r\n").unwrap(); |
Hm, what if you change the tcp example to call shutdown twice? // ...
stream.shutdown(net::Shutdown::Write).unwrap();
stream.shutdown(net::Shutdown::Write).unwrap();
// ... |
Yup, panics with the same error as the original test case.
|
Aha! So, seems Linux has no problem with that, but Mac does. Hyper calls shutdown if there's Close header in the request. The response is also sending a Close header, and so shutdown is called a second time in the response. I assumed it'd be a no-op if it was already closed... |
On OSX, calling shutdown a second time will return a NotConnected error. This commit will just ignore it, since we can agree that if a stream is "not connected", it is in fact "closed". Closes #508
On OSX, calling shutdown a second time will return a NotConnected error. This commit will just ignore it, since we can agree that if a stream is "not connected", it is in fact "closed". Closes #508
On OSX, calling shutdown a second time will return a NotConnected error. This commit will just ignore it, since we can agree that if a stream is "not connected", it is in fact "closed". Closes #508
Cheers, thanks for your help and responsiveness. |
Given this small sample program basically copied from the README:
The request always fails with a HttpIoError (NotConnected):
This is with OS X 10.10.3 (14D136) and
rustc 1.0.0-beta.4 (850151a75 2015-04-30) (built 2015-04-30)
. The same program works when run on a Ubuntu 14.04 VM with the same version of rust.It seems somewhat dependent on the URL, although more fail than don't. E.g. these work:
These do not:
The text was updated successfully, but these errors were encountered: