@fastify/reply-from
Advanced tools
Comparing version 8.4.0 to 8.4.1
@@ -8,3 +8,3 @@ 'use strict' | ||
const undici = require('undici') | ||
const { stripHttp1ConnectionHeaders } = require('./utils') | ||
const { patchUndiciHeaders, stripHttp1ConnectionHeaders } = require('./utils') | ||
const http2 = require('http2') | ||
@@ -162,3 +162,3 @@ | ||
done(null, { statusCode: res.statusCode, headers: res.headers, stream: res.body }) | ||
done(null, { statusCode: res.statusCode, headers: patchUndiciHeaders(res.headers), stream: res.body }) | ||
}) | ||
@@ -165,0 +165,0 @@ } |
@@ -15,2 +15,27 @@ function filterPseudoHeaders (headers) { | ||
// http requires the header to be encoded with latin1 | ||
// undici will convert the latin1 buffer to utf8 | ||
// https://github.com/nodejs/undici/blob/2b260c997ad4efe4ed2064b264b4b546a59e7a67/lib/core/util.js#L216-L229 | ||
// after chaining, the header will be serialised using wrong encoding | ||
// Buffer.from('', 'latin1').toString('utf8') applied | ||
// | ||
// in order to persist the encoding, always encode it | ||
// back to latin1 | ||
function patchUndiciHeaders (headers) { | ||
const headersKeys = Object.keys(headers) | ||
const dist = {} | ||
let header | ||
let i | ||
for (i = 0; i < headersKeys.length; i++) { | ||
header = headersKeys[i] | ||
if (header.charCodeAt(0) !== 58) { // fast path for indexOf(':') === 0 | ||
dist[header] = Buffer.from(headers[header]).toString('latin1') | ||
} | ||
} | ||
return dist | ||
} | ||
function copyHeaders (headers, reply) { | ||
@@ -78,2 +103,3 @@ const headersKeys = Object.keys(headers) | ||
module.exports = { | ||
patchUndiciHeaders, | ||
copyHeaders, | ||
@@ -80,0 +106,0 @@ stripHttp1ConnectionHeaders, |
{ | ||
"name": "@fastify/reply-from", | ||
"version": "8.4.0", | ||
"version": "8.4.1", | ||
"description": "forward your HTTP request to another server, for fastify", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166309
99
4930