1
0
Fork 0
mirror of https://github.com/sbrl/powahroot.git synced 2025-02-08 06:34:56 +00:00

Sender: add ; charset=utf-8 for all plain text + html responses

This commit is contained in:
Starbeamrainbowlabs 2025-01-08 15:49:07 +00:00
parent 49de8bf0dc
commit 4e2cd7e08f
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 6 additions and 2 deletions

View file

@ -15,6 +15,10 @@ npm install --save powahroot
-----
## v1.3.0 (unreleased)
- Sender: Append `; charset=utf-8` to `content-type` when sending plain / html responses
## v1.2.12
- Update dependencies

View file

@ -35,7 +35,7 @@ class Sender {
* @return {void}
*/
html_string(status_code, html_string) {
this.string(status_code, "text/html", html_string);
this.string(status_code, "text/html; charset=utf-8", html_string);
}
/**
* Sends a given thing of any type as a JSON response.
@ -68,7 +68,7 @@ class Sender {
*/
plain(status_code, data) {
this.response.writeHead(status_code, {
"content-type": "text/plain",
"content-type": "text/plain; charset=utf-8",
"content-length": Buffer.byteLength(data, "utf8"),
});
this.response.end(data);