Skip to content

Conversation

@arobase-che
Copy link

@arobase-che arobase-che commented Mar 15, 2024

Send the path to the URI field instead of the whole URI.

The goal is to make it works with unnamed server like local one 127.0.0.1:8080 or servers unaware of they own name (or alternative name).

I do not see any drawback to that change and I think it maybe more user-friendly to use relative URI here.

Edit: Oupsy ! I see one. The query part is missing.
I should have use path_and_query instead of path only. But it make it a lot more complex with something like that:

    let req = Request::builder()
        .uri(hyper::Uri::from_parts({
            let mut uri_ = <http::uri::Parts as std::default::Default>::default();
            uri_.path_and_query = url.path_and_query().cloned();
            uri_
        })?)
        .header(hyper::header::HOST, authority.as_str())
        .body(Empty::<Bytes>::new())?;

Maybe we can have something in between or maybe the initial code is well enough.
Thank you.

Send the path to the URI field instead of the whole URI.
@dswij
Copy link
Member

dswij commented Mar 15, 2024

Thanks for the PR!

The guide is specifically to send a GET request to httpbin:

going to send a GET [`Request`][Request] to [http://httpbin.org/ip](http://httpbin.org/ip),

@arobase-che
Copy link
Author

Oh ! Get it. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants