New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: set reply's default charset to utf8 #3789
Conversation
test/internals/reply.test.js
Outdated
|
||
fastify.listen({ port: 0 }, err => { | ||
t.error(err) | ||
fastify.server.unref() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it is used in other tests, but could you use the t.teaddown
function instead of server.unref
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL, but I want to know what is the difference between t.teardown
& server.unref
, more semantic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.teardown
run when the test end and you can provide callback
function to exit the environment cleanly.
server.unref
just didn't block the program end when no code need to run inside the event loop. It is an unclean close.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot! This is an amazing speed bump. How did you find it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ✌️
Thanks for the bug report, and I find these codes can be more simplified |
@@ -261,6 +261,7 @@ Sets the content type for the response. This is a shortcut for | |||
```js | |||
reply.type('text/html') | |||
``` | |||
When set `Content-Type` with json type, if you don't set `charset`, it will use `utf-8` by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When set `Content-Type` with json type, if you don't set `charset`, it will use `utf-8` by default. | |
If the `Content-Type` has a JSON subtype, and the charset parameter is not set, `utf-8` will be used as the charset by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, I missed this. I'll amend on main.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers @mcollina!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
ref: #3788
Checklist
npm run test
andnpm run benchmark
and the Code of conduct