Skip to content

Commit 60def8d

Browse files
author
Don McCurdy
committed
Escape IPv6 address regardless of whether port is specified.
1 parent 7546030 commit 60def8d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/XMLHttpRequest.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,11 @@ 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)) {
347-
if (url.host[0] === '[') {
348-
headers.Host = '[' + headers.Host + ']';
349-
}
350351
headers.Host += ":" + url.port;
351352
}
352353

0 commit comments

Comments
 (0)