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

fix InvalidDNSNameError when using ip inside url #32

Closed
wants to merge 1 commit into from

Conversation

oyundev
Copy link

@oyundev oyundev commented Jul 22, 2020

Works fine: get->url = "https://raw.githubusercontent.com/.../master/LICENSE-APACHE"
Fails: get->url = "https://151.101.0.133/.../master/LICENSE-APACHE"
with error: IoError(Custom { kind: Other, error: InvalidDNSNameError })

Requests should respect Host entry from request headers, following changes fixed it for me.

1.inside request.rs:
headers: HashMap<String, String>, => pub(crate) headers: HashMap<String, String>,
2.inside connection.rs:
let dns_name = &self.request.host; => let dns_name = self.request.headers.get("Host").unwrap_or(&self.request.host);

@neonmoe
Copy link
Owner

neonmoe commented Sep 27, 2020

Thanks for the PR, and sorry for not responding earlier. I imagine I saw this in my inbox one morning and forgot.

The host header is actually set based on request.host, see Request::get_http_head. So generally you should not be setting the host header via the header API, instead you should be including the right host in the URL itself.

I'm not sure how this change fixed it for you, but the DNS handling should definitely be skipped if the host is an IP address, so I opened #34. In any case, I'll close this since I don't see how this would actually fix the problem.

If I misunderstood something, please reopen the PR, I'll gladly re-review it then.

@neonmoe neonmoe closed this Sep 27, 2020
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.

None yet

2 participants