@@ -148,20 +148,20 @@ function getRequestHeaders (ctx) {
148148 const key = headers [ n + 0 ]
149149 const val = headers [ n + 1 ]
150150
151- if ( ! via && key . length === 3 && / ^ v i a $ / i . test ( key ) ) {
151+ if ( ! via && key . length === 3 && key . toLowerCase ( ) === 'via' ) {
152152 via = val
153- } else if ( ! host && key . length === 4 && / ^ h o s t $ / i . test ( key ) ) {
153+ } else if ( ! host && key . length === 4 && key . toLowerCase ( ) === 'host' ) {
154154 host = val
155- } else if ( ! forwarded && key . length === 9 && / ^ f o r w a r d e d $ / . test ( key ) ) {
155+ } else if ( ! forwarded && key . length === 9 && key . toLowerCase ( ) === 'forwarded' ) {
156156 forwarded = val
157- } else if ( ! authority && key . length === 10 && / ^ : a u t h o r i t y $ / i. test ( key ) ) {
158- authority = val
159- } else if ( ! connection && key . length === 10 && / ^ c o n n e c t i o n $ / i. test ( key ) ) {
157+ } else if ( ! connection && key . length === 10 && key . toLowerCase ( ) === 'connection' ) {
160158 connection = val
159+ } else if ( ! authority && key . length === 10 && key === ':authority' ) {
160+ authority = val
161161 }
162162 }
163163
164- const result = copyHeaders ( headers )
164+ const result = copyHeaders ( headers , connection )
165165
166166 // TODO(fix): <host> [ ":" <port> ] vs <pseudonym>
167167 // See, https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Via.
@@ -189,18 +189,18 @@ function getRequestHeaders (ctx) {
189189 return result
190190}
191191
192- // This expression matched hop-by-hop headers.
192+ // This expression matches hop-by-hop headers.
193193// These headers are meaningful only for a single transport-level connection,
194194// and must not be retransmitted by proxies or cached.
195- // Note that only hop-by-hop headers may be set using the Connection general header.
196195const HOP_EXPR = / ^ ( t e | h o s t | u p g r a d e | t r a i l e r s | c o n n e c t i o n | k e e p - a l i v e | h t t p 2 - s e t t i n g s | t r a n s f e r - e n c o d i n g | p r o x y - c o n n e c t i o n | p r o x y - a u t h e n t i c a t e | p r o x y - a u t h o r i z a t i o n ) $ / i
197196
198197// Removes hop-by-hop and pseudo headers.
198+ // Only hop-by-hop headers may be set using the Connection general header.
199199function copyHeaders ( headers , connection ) {
200200 if ( ! connection ) {
201201 for ( let n = 0 ; n < headers . length ; n += 2 ) {
202202 const key = headers [ n + 0 ]
203- if ( key . length === 10 && / ^ c o n n e c t i o n $ / i . test ( key ) ) {
203+ if ( key . length === 10 && key . toLowerCase ( ) === 'connection' ) {
204204 connection = headers [ n + 1 ]
205205 break
206206 }
0 commit comments