hyper: HTTPS Request: Invalid scheme for Http
I’m currently building against v0.10 and am experiencing some issues trying to send a request on macOS 10.12.
Here’s a minimal example.
extern crate hyper;
use hyper::Client;
use hyper::Url;
fn main() {
let url = "https://httpbin.org/get";
let url = Url::parse(&url).unwrap();
println!("{:?}", url);
let client = Client::new();
let res = client.get(url).send();
println!("{:?}", res);
}
"https://httpbin.org/get"
Err(Io(Error { repr: Custom(Custom { kind: InvalidInput, error: StringError("Invalid scheme for Http") }) })
When I build against hyper = { version = "0.9", default-features = false, features = ["security-framework"] }
this example runs just fine, so I’m guessing the issue has something to do with macOS’ security-framework handling in hyper?
The error does not occur when requesting http://httpbin.org/get.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 18 (6 by maintainers)
Commits related to this issue
- Update dependencies Add native-tls + hyper-native-tls (see https://github.com/hyperium/hyper/issues/1009) for now — committed to mmitteregger/rust-twitch-client by mmitteregger 7 years ago
- Use hyper-native-tls for https Related issue: <https://github.com/hyperium/hyper/issues/1009> — committed to yvt/cfdyndns by yvt 5 years ago
- Use hyper-native-tls for https Related issue: <https://github.com/hyperium/hyper/issues/1009> — committed to yvt/cfdyndns by yvt 5 years ago
Just ran into this. A couple of suggestions:
Error { repr: Custom(Custom { kind: InvalidInput, error: NotHttp }) }
which doesn’t tell me very much about what is going onI guess the good news is that when I searched for http-1009 this was the 2nd entry in Google’s results, and the first one I clicked on, so you accomplished making information available for others who need help.
Just ran into this. I copy and pasted the snippet from the client guide, and changed the URL to https scheme, boom. This is 2019, please look around: plain http is not used any more. As for your example, http://httpbin.org: if i enter “httpbin.org” into my browser URL, it will use https://httpbin.org.
By default, a Client can only speak to HTTP addresses.
This is so last year. Compare toBy default, a Client can only speak to HTTPS addresses using TLS 1.3
https should be the default, and the #1 rust http client library that shows up on Google (via https) should support it out-of-the-box, or have a feature matrix as the first section that clearly states that https requires extra effort. I’m already prepared to find out hyper doesn’t support proxies 😉
This error is still as-is, in 2022.
Ah, I see. Thanks for the link and reasoning!
Would it be possible to make the error messages a little more clear though than they currently are? I tried quite a bit to debug this and was unable to find out anything by looking around with the error message. It probably would’ve helped if I’ve looked in the issues here more closely, but a quick search didn’t show anything 😕
hyper no longer includes a default TLS library, so you’ll need to pick one. I’d recommend hyper-native-tls.
See #985 for reasoning.
https://docs.rs/hyper/0.13.2/hyper/client/struct.HttpConnector.html#method.enforce_http
I could certainly see value in adding a
error!("HttpConnector used to connect to HTTPS URL, try using HttpsConnector with an SSL implementation")
or similar just before returning theErr
.