File tree 2 files changed +15
-10
lines changed
2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -280,13 +280,13 @@ function parseRawHeaders (headers) {
280
280
let contentDispositionIdx = - 1
281
281
282
282
for ( let n = 0 ; n < headers . length ; n += 2 ) {
283
- const key = headers [ n + 0 ] . toString ( )
283
+ const key = headerNameToString ( headers [ n ] )
284
284
const val = headers [ n + 1 ] . toString ( 'utf8' )
285
285
286
- if ( key . length === 14 && ( key === 'content-length' || key . toLowerCase ( ) === 'content-length' ) ) {
286
+ if ( key === 'content-length' ) {
287
287
ret . push ( key , val )
288
288
hasContentLength = true
289
- } else if ( key . length === 19 && ( key === 'content-disposition' || key . toLowerCase ( ) === 'content-disposition' ) ) {
289
+ } else if ( key === 'content-disposition' ) {
290
290
contentDispositionIdx = ret . push ( key , val ) - 1
291
291
} else {
292
292
ret . push ( key , val )
Original file line number Diff line number Diff line change @@ -176,20 +176,25 @@ function parseLocation (statusCode, headers) {
176
176
}
177
177
178
178
for ( let i = 0 ; i < headers . length ; i += 2 ) {
179
- if ( headers [ i ] . toString ( ) . toLowerCase ( ) === 'location' ) {
179
+ if ( headers [ i ] . length === 8 && util . headerNameToString ( headers [ i ] ) === 'location' ) {
180
180
return headers [ i + 1 ]
181
181
}
182
182
}
183
183
}
184
184
185
185
// https://tools.ietf.org/html/rfc7231#section-6.4.4
186
186
function shouldRemoveHeader ( header , removeContent , unknownOrigin ) {
187
- return (
188
- ( header . length === 4 && header . toString ( ) . toLowerCase ( ) === 'host' ) ||
189
- ( removeContent && header . toString ( ) . toLowerCase ( ) . indexOf ( 'content-' ) === 0 ) ||
190
- ( unknownOrigin && header . length === 13 && header . toString ( ) . toLowerCase ( ) === 'authorization' ) ||
191
- ( unknownOrigin && header . length === 6 && header . toString ( ) . toLowerCase ( ) === 'cookie' )
192
- )
187
+ if ( header . length === 4 ) {
188
+ return util . headerNameToString ( header ) === 'host'
189
+ }
190
+ if ( removeContent && util . headerNameToString ( header ) . startsWith ( 'content-' ) ) {
191
+ return true
192
+ }
193
+ if ( unknownOrigin && ( header . length === 13 || header . length === 6 ) ) {
194
+ const name = util . headerNameToString ( header )
195
+ return name === 'authorization' || name === 'cookie'
196
+ }
197
+ return false
193
198
}
194
199
195
200
// https://tools.ietf.org/html/rfc7231#section-6.4
You can’t perform that action at this time.
0 commit comments