summaryrefslogtreecommitdiff
path: root/lib/_http_client.js
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2017-05-19 17:14:53 -0400
committerBrian White <mscdex@mscdex.net>2017-05-22 23:04:33 -0400
commit3774c99f668173175c35f64c92499c93277df5f2 (patch)
tree5f092a35ecad8743ce3f7bcc15cda3c61cd3abe1 /lib/_http_client.js
parented365653f6eb74d58a1d2a1c1bdb20e4baf67fa0 (diff)
downloadandroid-node-v8-3774c99f668173175c35f64c92499c93277df5f2.tar.gz
android-node-v8-3774c99f668173175c35f64c92499c93277df5f2.tar.bz2
android-node-v8-3774c99f668173175c35f64c92499c93277df5f2.zip
http: fix IPv6 Host header check
PR-URL: https://github.com/nodejs/node/pull/13122 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'lib/_http_client.js')
-rw-r--r--lib/_http_client.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js
index 3e1ed88827..7707fa74cf 100644
--- a/lib/_http_client.js
+++ b/lib/_http_client.js
@@ -173,14 +173,14 @@ function ClientRequest(options, cb) {
}
if (host && !this.getHeader('host') && setHost) {
var hostHeader = host;
- var posColon = -1;
// For the Host header, ensure that IPv6 addresses are enclosed
// in square brackets, as defined by URI formatting
// https://tools.ietf.org/html/rfc3986#section-3.2.2
- if (-1 !== (posColon = hostHeader.indexOf(':')) &&
- -1 !== (posColon = hostHeader.indexOf(':', posColon)) &&
- '[' !== hostHeader[0]) {
+ var posColon = hostHeader.indexOf(':');
+ if (posColon !== -1 &&
+ hostHeader.indexOf(':', posColon + 1) !== -1 &&
+ hostHeader.charCodeAt(0) !== 91/*'['*/) {
hostHeader = `[${hostHeader}]`;
}