hyperium / http

Rust HTTP types

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can't parse uri without scheme but having path

swanandx opened this issue · comments

I expect example.org/path to be valid Uri, but parse() returns an InvalidFormat error

use http::Uri;

fn main() {
    let uri: Uri = "example.org/path".parse().unwrap();

    dbg!(uri.authority());
}

// ^this will result in:
// thread 'main' panicked at src/main.rs:4:47:
// called `Result::unwrap()` on an `Err` value: InvalidUri(InvalidFormat)

note: http://example.org/path is parsed correctly!

This is working as intended. See #523 for details.

Exactly. That is not a valid Uri. There are 4 main options, defined in the HTTP specs.

Oh, using this for connecting to servers was quite common like broker.mqttdashboard.com/mqtt, so I thought it's valid 😅

Thanks for your response, can you please point me to the specific part in standards 😁