File tree 3 files changed +24
-1
lines changed
3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -754,7 +754,7 @@ Request.prototype.request = function () {
754
754
options . method = this . method ;
755
755
options . port = url . port ;
756
756
options . path = path ;
757
- options . host = url . hostname ;
757
+ options . host = utils . normalizeHostname ( url . hostname ) ; // ex: [::1] -> ::1
758
758
options . ca = this . _ca ;
759
759
options . key = this . _key ;
760
760
options . pfx = this . _pfx ;
Original file line number Diff line number Diff line change @@ -72,6 +72,11 @@ exports.cleanHeader = (header, changesOrigin) => {
72
72
return header ;
73
73
} ;
74
74
75
+ exports . normalizeHostname = ( hostname ) => {
76
+ const [ , normalized ] = hostname . match ( / ^ \[ ( [ ^ \] ] + ) \] $ / ) || [ ] ;
77
+ return normalized || hostname ;
78
+ } ;
79
+
75
80
/**
76
81
* Check if `obj` is an object.
77
82
*
Original file line number Diff line number Diff line change @@ -134,6 +134,24 @@ describe('[node] request', () => {
134
134
} ) ;
135
135
} ) ;
136
136
137
+ if ( doesntWorkInHttp2 ) {
138
+ describe ( 'ipv6 address' , ( ) => {
139
+ it ( 'should successfully query an ipv6 address' , ( done ) => {
140
+ request . get ( `http://[::]:${ process . env . ZUUL_PORT } /url?a=(b%29` ) . end ( ( error , res ) => {
141
+ assert . equal ( '/url?a=(b%29' , res . text ) ;
142
+ done ( ) ;
143
+ } ) ;
144
+ } ) ;
145
+
146
+ it ( 'should successfully query an ipv6 address' , ( done ) => {
147
+ request . get ( `http://[::1]:${ process . env . ZUUL_PORT } /url?a=(b%29` ) . end ( ( error , res ) => {
148
+ assert . equal ( '/url?a=(b%29' , res . text ) ;
149
+ done ( ) ;
150
+ } ) ;
151
+ } ) ;
152
+ } ) ;
153
+ }
154
+
137
155
describe ( '.buffer()' , ( ) => {
138
156
it ( 'should enable buffering' , ( done ) => {
139
157
request
You can’t perform that action at this time.
0 commit comments