Skip to content

Commit 97966e4

Browse files
authored
Merge pull request #164 from donmccurdy/feat-ipv6-host-header
Include brackets for IPv6 host header.
2 parents 08577de + 60def8d commit 97966e4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/XMLHttpRequest.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ exports.XMLHttpRequest = function() {
111111
this.responseXML = "";
112112
this.status = null;
113113
this.statusText = null;
114-
114+
115115
// Whether cross-site Access-Control requests should be made using
116116
// credentials such as cookies or authorization headers
117117
this.withCredentials = false;
@@ -343,6 +343,10 @@ exports.XMLHttpRequest = function() {
343343

344344
// Set the Host header or the server may reject the request
345345
headers.Host = host;
346+
// IPv6 addresses must be escaped with brackets
347+
if (url.host[0] === "[") {
348+
headers.Host = "[" + headers.Host + "]";
349+
}
346350
if (!((ssl && port === 443) || port === 80)) {
347351
headers.Host += ":" + url.port;
348352
}

0 commit comments

Comments
 (0)