byte size of the response #4627
-
is there any way i can get and record the size of the response returned from a route? |
Beta Was this translation helpful? Give feedback.
Answered by
Eomm
Mar 14, 2023
Replies: 2 comments 1 reply
-
Not at the moment. Though can be an interesting addition 🤔 As a workaround, you can measure the byte length of your request on the |
Beta Was this translation helpful? Give feedback.
0 replies
-
Do you mean like this? const fastify = require('fastify')({ logger: !true });
fastify.get(
'/',
{
onResponse: function hook(request, reply, done) {
console.log(reply.raw.getHeader('Content-Length'));
done();
},
},
async (request, reply) => {
return 'a'.repeat(42);
}
);
fastify.inject('/').then((response) => {}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
metcoder95
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you mean like this?