Skip to content

Commit a5ccaa6

Browse files
committed
fixup
1 parent fddfabc commit a5ccaa6

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

examples/proxy/proxy.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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 && /^via$/i.test(key)) {
151+
if (!via && key.length === 3 && key.toLowerCase() === 'via') {
152152
via = val
153-
} else if (!host && key.length === 4 && /^host$/i.test(key)) {
153+
} else if (!host && key.length === 4 && key.toLowerCase() === 'host') {
154154
host = val
155-
} else if (!forwarded && key.length === 9 && /^forwarded$/.test(key)) {
155+
} else if (!forwarded && key.length === 9 && key.toLowerCase() === 'forwarded') {
156156
forwarded = val
157-
} else if (!authority && key.length === 10 && /^:authority$/i.test(key)) {
158-
authority = val
159-
} else if (!connection && key.length === 10 && /^connection$/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.
196195
const HOP_EXPR = /^(te|host|upgrade|trailers|connection|keep-alive|http2-settings|transfer-encoding|proxy-connection|proxy-authenticate|proxy-authorization)$/i
197196

198197
// Removes hop-by-hop and pseudo headers.
198+
// Only hop-by-hop headers may be set using the Connection general header.
199199
function 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 && /^connection$/i.test(key)) {
203+
if (key.length === 10 && key.toLowerCase() === 'connection') {
204204
connection = headers[n + 1]
205205
break
206206
}

0 commit comments

Comments
 (0)