Skip to content

Client request omits port from host #88

@hannobraun

Description

@hannobraun

I'm sending a request to localhost:<port>/some-url and expect the server to redirect me to localhost:<port>/another-url, however, the server redirects me to localhost:80/another-url instead. I think the reason for this is that hyper sets the Host header of the client request to localhost, not localhost:<port> as it should.

The header is set here:

headers.set(Host(host));

The host the header is set to is extracted from the Urlhere:
let host = match url.serialize_host() {

I've confirmed that serialize_host omits the port. Example code:

use hyper::Url;

let url = Url::parse("http://localhost:12345/some-url").unwrap();
print!("url: {}\n", url);
print!("url.serialize_host().unwrap(): {}\n", url.serialize_host().unwrap());

Output:

url: http://localhost:12345/some-url
url.serialize_host().unwrap(): localhost

What I don't know is whether the problem lies with serialize_host or if it is used incorrectly in Request::with_stream. Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions