Specify UTF-8 for non-binary content-types
If charset is unspecified, the encoding falls back to ISO 8859-1 or something else that is defined in HTTP/1.1. Given there is no reason not to use UTF-8 nowadays[0] and one can convert legacy encodings to UTF-8 easily, if the case comes up, it is a sane default to specify it in the config.def.h. [0]: https://utf8everywhere.org/ Signed-off-by: Laslo Hunhold <dev@frign.de>
This commit is contained in:
parent
d2013a6337
commit
bbd47e1427
3 changed files with 12 additions and 12 deletions
20
config.def.h
20
config.def.h
|
@ -6,15 +6,15 @@ static const struct {
|
||||||
char *ext;
|
char *ext;
|
||||||
char *type;
|
char *type;
|
||||||
} mimes[] = {
|
} mimes[] = {
|
||||||
{ "xml", "application/xml" },
|
{ "xml", "application/xml; charset=utf-8" },
|
||||||
{ "xhtml", "application/xhtml+xml" },
|
{ "xhtml", "application/xhtml+xml; charset=utf-8" },
|
||||||
{ "html", "text/html; charset=UTF-8" },
|
{ "html", "text/html; charset=utf-8" },
|
||||||
{ "htm", "text/html; charset=UTF-8" },
|
{ "htm", "text/html; charset=utf-8" },
|
||||||
{ "css", "text/css" },
|
{ "css", "text/css; charset=utf-8" },
|
||||||
{ "txt", "text/plain" },
|
{ "txt", "text/plain; charset=utf-8" },
|
||||||
{ "md", "text/plain" },
|
{ "md", "text/plain; charset=utf-8" },
|
||||||
{ "c", "text/plain" },
|
{ "c", "text/plain; charset=utf-8" },
|
||||||
{ "h", "text/plain" },
|
{ "h", "text/plain; charset=utf-8" },
|
||||||
{ "gz", "application/x-gtar" },
|
{ "gz", "application/x-gtar" },
|
||||||
{ "tar", "application/tar" },
|
{ "tar", "application/tar" },
|
||||||
{ "pdf", "application/x-pdf" },
|
{ "pdf", "application/x-pdf" },
|
||||||
|
@ -24,7 +24,7 @@ static const struct {
|
||||||
{ "jpg", "image/jpg" },
|
{ "jpg", "image/jpg" },
|
||||||
{ "iso", "application/x-iso9660-image" },
|
{ "iso", "application/x-iso9660-image" },
|
||||||
{ "webp", "image/webp" },
|
{ "webp", "image/webp" },
|
||||||
{ "svg", "image/svg+xml" },
|
{ "svg", "image/svg+xml; charset=utf-8" },
|
||||||
{ "flac", "audio/flac" },
|
{ "flac", "audio/flac" },
|
||||||
{ "mp3", "audio/mpeg" },
|
{ "mp3", "audio/mpeg" },
|
||||||
{ "ogg", "audio/ogg" },
|
{ "ogg", "audio/ogg" },
|
||||||
|
|
2
http.c
2
http.c
|
@ -58,7 +58,7 @@ http_send_status(int fd, enum status s)
|
||||||
"Date: %s\r\n"
|
"Date: %s\r\n"
|
||||||
"Connection: close\r\n"
|
"Connection: close\r\n"
|
||||||
"%s"
|
"%s"
|
||||||
"Content-Type: text/html\r\n"
|
"Content-Type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"<!DOCTYPE html>\n<html>\n\t<head>\n"
|
"<!DOCTYPE html>\n<html>\n\t<head>\n"
|
||||||
"\t\t<title>%d %s</title>\n\t</head>\n\t<body>\n"
|
"\t\t<title>%d %s</title>\n\t</head>\n\t<body>\n"
|
||||||
|
|
2
resp.c
2
resp.c
|
@ -56,7 +56,7 @@ resp_dir(int fd, char *name, struct request *r)
|
||||||
"HTTP/1.1 %d %s\r\n"
|
"HTTP/1.1 %d %s\r\n"
|
||||||
"Date: %s\r\n"
|
"Date: %s\r\n"
|
||||||
"Connection: close\r\n"
|
"Connection: close\r\n"
|
||||||
"Content-Type: text/html\r\n"
|
"Content-Type: text/html; charset=utf-8\r\n"
|
||||||
"\r\n",
|
"\r\n",
|
||||||
S_OK, status_str[S_OK], timestamp(time(NULL), t)) < 0) {
|
S_OK, status_str[S_OK], timestamp(time(NULL), t)) < 0) {
|
||||||
s = S_REQUEST_TIMEOUT;
|
s = S_REQUEST_TIMEOUT;
|
||||||
|
|
Loading…
Reference in a new issue