Skip to content

Include brackets for IPv6 host header. #164

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

Merged
merged 2 commits into from
Mar 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ exports.XMLHttpRequest = function() {
this.responseXML = "";
this.status = null;
this.statusText = null;

// Whether cross-site Access-Control requests should be made using
// credentials such as cookies or authorization headers
this.withCredentials = false;
Expand Down Expand Up @@ -343,6 +343,10 @@ exports.XMLHttpRequest = function() {

// Set the Host header or the server may reject the request
headers.Host = host;
// IPv6 addresses must be escaped with brackets
if (url.host[0] === "[") {
headers.Host = "[" + headers.Host + "]";
}
if (!((ssl && port === 443) || port === 80)) {
headers.Host += ":" + url.port;
}
Expand Down