mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
section 16: Phase 16: Documentation, container ports and full repository checks
This commit is contained in:
1 parent
81a9f0c8ef
commit
a383e57bc5
55 files changed
+4095
-59
No files matched your search
@@ -0,0 +1,40 @@
|
||||
export const HOP_BY_HOP_HEADERS = new Set([
|
||||
'connection',
|
||||
'keep-alive',
|
||||
'proxy-authenticate',
|
||||
'proxy-authorization',
|
||||
'te',
|
||||
'trailers',
|
||||
'upgrade',
|
||||
'transfer-encoding',
|
||||
'content-length',
|
||||
'content-encoding',
|
||||
'host',
|
||||
'authorization',
|
||||
])
|
||||
|
||||
export function filterProxyHeaders(
|
||||
headers: Headers,
|
||||
extraExcluded: ReadonlySet<string> = new Set(),
|
||||
): Record<string, string> {
|
||||
const result: Record<string, string> = {}
|
||||
headers.forEach((value, key) => {
|
||||
const lowerKey = key.toLowerCase()
|
||||
if (HOP_BY_HOP_HEADERS.has(lowerKey) || extraExcluded.has(lowerKey)) return
|
||||
result[key] = value
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
export function buildProxyResponseHeaders(
|
||||
source: Headers,
|
||||
extraExcluded: ReadonlySet<string> = new Set(),
|
||||
): Headers {
|
||||
const excluded = new Set(extraExcluded)
|
||||
excluded.add('set-cookie')
|
||||
const headers = new Headers(filterProxyHeaders(source, excluded))
|
||||
for (const cookie of source.getSetCookie()) {
|
||||
headers.append('set-cookie', cookie)
|
||||
}
|
||||
return headers
|
||||
}
|
||||
Reference in new issue
Block a user