upstream-response-headers.mjs
sha256:94ec65bd2b200240ac785a97cf14c5db066832bd608a24d6a9c151f17b918b02
feat(calendar): hosted bridge/gateway route parity and time…
Human
minor
⚠ breaking
1 day ago
| 1 | /** |
| 2 | * When the gateway proxies with fetch().text(), the body is already decoded. |
| 3 | * Forwarding upstream Content-Encoding (e.g. br) causes browsers to ERR_CONTENT_DECODING_FAILED. |
| 4 | */ |
| 5 | |
| 6 | const STRIP_FROM_UPSTREAM_DECODED_BODY = new Set([ |
| 7 | 'content-encoding', |
| 8 | 'content-length', |
| 9 | 'transfer-encoding', |
| 10 | 'connection', |
| 11 | 'access-control-allow-origin', |
| 12 | 'access-control-allow-methods', |
| 13 | 'access-control-allow-headers', |
| 14 | 'access-control-allow-credentials', |
| 15 | 'access-control-expose-headers', |
| 16 | 'access-control-max-age', |
| 17 | ]); |
| 18 | |
| 19 | /** |
| 20 | * @param {Iterable<[string, string]>} entries - upstream Response.headers entries |
| 21 | * @returns {[string, string][]} |
| 22 | */ |
| 23 | export function filterUpstreamResponseHeadersForDecodedBody(entries) { |
| 24 | return [...entries].filter(([k]) => !STRIP_FROM_UPSTREAM_DECODED_BODY.has(k.toLowerCase())); |
| 25 | } |
File History
1 commit
sha256:94ec65bd2b200240ac785a97cf14c5db066832bd608a24d6a9c151f17b918b02
feat(calendar): hosted bridge/gateway route parity and time…
Human
minor
⚠
1 day ago