fastify decompress using preParsing hook
davidkjackson54 opened this issue · comments
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
3.21.6
Plugin version
No response
Node.js version
16.2
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
10
Description
I am using fastify compress and it is working fine to compress a large string and returns to the client with no issues.
My problem is when the client sends content-encoding gzip and content-length of 462 with gzip'd payload, The uncompressed length is 1325 bytes.
authorization: 'Basic xxxxxxxxxxxxxxxxxxxxxx==',
'accept-encoding': 'br, deflate, gzip',
'content-type': 'text/plain',
'content-encoding': 'gzip',
'content-length': '462',
host: 'localhost:3000',
connection: 'close'
I appear to have 2 problems..
When the preparsing hook fires, I have looked in the payload and do not see anything that remotely looks like the 426 bytes of gzipped content. I don't appear to see it anywhere.
server.addHook("preParsing", (request, reply, payload, done) => {
done(null, payload);
});
Where in the payload field is the inbound data expected to be found?
When the preparsing hook exits, fastify reports this:
Request body size did not match Content-Length
"name": "FastifyError",
"code": "FST_ERR_CTP_INVALID_CONTENT_LENGTH",
"statusCode": 400
If I switch my client to point at our current Tomcat server it works fine.
Steps to Reproduce
Not easy as there is a lot of code involved here with many external dependencies.
Expected Behavior
Would expect to have uncompressed data on exit from preParsing hook..
Making progress . Closing
@davidkjackson54 Hi, got the same problem, how did you manage to solve it?