Prerequisites
Fastify version
4.12.0
Plugin version
8.3.1
Node.js version
16.19.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.1
Description
When a header is set using a character like å (Norwegian character) its encoding gets messed up. A fastify server serving it serializes correctly, but if reply-from is used, the encoding changes. If another server with reply-from is chained, the app crashes with TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["content-disposition"].
Steps to Reproduce
const replyFrom = require('@fastify/reply-from');
const fastify = require('fastify');
const app = fastify();
app.get('/', (_request, reply) => {
reply.header('content-disposition', 'år.pdf').send('OK');
});
app.listen({ port: 6666 });
const proxy = fastify();
proxy.register(replyFrom);
proxy.get('/', (_request, reply) => {
return reply.from('http://localhost:6666');
});
proxy.listen({ port: 7777 });
const secondProxy = fastify();
secondProxy.register(replyFrom);
secondProxy.get('/', (_request, reply) => {
return reply.from('http://localhost:7777');
});
secondProxy.listen({ port: 8888 });
$ curl -i http://localhost:6666
HTTP/1.1 200 OK
content-disposition: år.pdf
content-type: text/plain; charset=utf-8
content-length: 2
Date: Fri, 27 Jan 2023 15:47:49 GMT
Connection: keep-alive
Keep-Alive: timeout=72
$ curl -i http://localhost:7777
HTTP/1.1 200 OK
content-disposition: r.pdf
content-type: text/plain; charset=utf-8
content-length: 2
date: Fri, 27 Jan 2023 15:47:52 GMT
connection: keep-alive
keep-alive: timeout=72
$ curl -i http://localhost:8888
curl: (52) Empty reply from server
Expected Behavior
The header should be correctly encoded and decoded (i.e. 7777 and 8888 should have the same result as 6666).
If that's not possible I expect the first server to complain when the header is added.
Prerequisites
Fastify version
4.12.0
Plugin version
8.3.1
Node.js version
16.19.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.1
Description
When a header is set using a character like
å(Norwegian character) its encoding gets messed up. A fastify server serving it serializes correctly, but ifreply-fromis used, the encoding changes. If another server withreply-fromis chained, the app crashes withTypeError [ERR_INVALID_CHAR]: Invalid character in header content ["content-disposition"].Steps to Reproduce
Expected Behavior
The header should be correctly encoded and decoded (i.e.
7777and8888should have the same result as6666).If that's not possible I expect the first server to complain when the header is added.