Skip to content
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

HTTPS Request: Invalid scheme for Http #1009

Closed
kiliankoe opened this issue Jan 16, 2017 · 18 comments
Closed

HTTPS Request: Invalid scheme for Http #1009

kiliankoe opened this issue Jan 16, 2017 · 18 comments

Comments

@kiliankoe
Copy link

kiliankoe commented Jan 16, 2017

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.

@kiliankoe kiliankoe changed the title Invalid scheme for Http HTTPS Request: Invalid scheme for Http Jan 16, 2017
@seanmonstar
Copy link
Member

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.

@kiliankoe
Copy link
Author

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 😕

@seanmonstar
Copy link
Member

seanmonstar commented Jan 16, 2017

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 the Err.

@kiliankoe
Copy link
Author

That would be great!

@seanmonstar
Copy link
Member

Of course, this would only alert you if you had some sort of logger setup...

Separately, I wonder if it makes sense to change from suggesting Client::new() to Client::http() (or even Client::plaintext()?), so it is explicit that the client won't be able to connect to HTTPS.

mmitteregger added a commit to mmitteregger/rust-twitch-client that referenced this issue Apr 1, 2017
Add native-tls + hyper-native-tls (see hyperium/hyper#1009) for now
@PReinie
Copy link

PReinie commented Apr 6, 2017

I 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.

@NoraCodes
Copy link

Does this work with 0.11.0? It seems that hyper::net no longer exists.

@william20111
Copy link

Does this work with 0.11.0? It seems that hyper::net no longer exists.

This ^ im currently using 0.10 as hyper::net is gone. Any update on this..?

@tesaguri
Copy link
Contributor

tesaguri commented Jun 30, 2017

You can use hyper-tls. The guide explains how to use it with v0.11.

@wez
Copy link

wez commented Sep 16, 2017

Just ran into this. A couple of suggestions:

  • The client guide buries this issue under "Client Configuration" which is several steps too late into the flow. Please make a point of calling out that an additional crate is required to do TLS.
  • Please consider breaking the TLS portion of "Client Configuration" into a separate "Enabling HTTPS" section to make this clearer to folks skimming docs.
  • Please make the error message more directive. This is bubbling up in my first client integration as Error { repr: Custom(Custom { kind: InvalidInput, error: NotHttp }) } which doesn't tell me very much about what is going on

yvt added a commit to yvt/cfdyndns that referenced this issue Jan 2, 2019
yvt added a commit to yvt/cfdyndns that referenced this issue Jan 2, 2019
@jhinrichsen
Copy link

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 to

By 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 ;)

@Hexilee
Copy link

Hexilee commented Feb 28, 2020

Why does this code still run into the error "invalid URL, scheme is not http".

@sfackler
Copy link
Contributor

https://docs.rs/hyper/0.13.2/hyper/client/struct.HttpConnector.html#method.enforce_http

@Hexilee
Copy link

Hexilee commented Feb 28, 2020

Thx

@David-OConnor
Copy link

This error is still as-is, in 2022.

@ash-hashtag
Copy link

I don't know why but it worked for the last month, even with https urls, I didn't use any tls crates, and now it is throwing this error

@ash-hashtag
Copy link

You can use hyper-tls. The guide explains how to use it with v0.11.

the page is not there anymore

@sfackler
Copy link
Contributor

Commenting on 5 year old issues is not the best way to get assistance.

https://hyper.rs/guides/0.14/client/configuration/

@hyperium hyperium locked and limited conversation to collaborators Jan 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests