Skip to content

Commit

Permalink
Merge pull request #164 from donmccurdy/feat-ipv6-host-header
Browse files Browse the repository at this point in the history
Include brackets for IPv6 host header.
  • Loading branch information
driverdan authored Mar 29, 2018
2 parents 08577de + 60def8d commit 97966e4
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 97966e4

Please sign in to comment.