Skip to content

Instantly share code, notes, and snippets.

@milkey-mouse
Last active August 16, 2017 05:03
Show Gist options
  • Save milkey-mouse/1d96e72a0af8c3e56736af42f922c6bc to your computer and use it in GitHub Desktop.
Save milkey-mouse/1d96e72a0af8c3e56736af42f922c6bc to your computer and use it in GitHub Desktop.
Set the charset of all text MIME-typed requests to utf-8 (hacky)
Index: server_http.c
===================================================================
RCS file: /cvs/src/usr.sbin/httpd/server_http.c,v
retrieving revision 1.117
diff -u -p -r1.117 server_http.c
--- server_http.c 15 May 2017 10:40:47 -0000 1.117
+++ server_http.c 18 Jul 2017 02:51:19 -0000
@@ -1388,7 +1388,8 @@ server_response_http(struct client *clt,
/* Set media type */
if ((ct = kv_add(&resp->http_headers, "Content-Type", NULL)) == NULL ||
- kv_set(ct, "%s/%s", media->media_type, media->media_subtype) == -1)
+ kv_set(ct, "%s/%s%s", media->media_type, media->media_subtype,
+ strcmp(media->media_type, "text") ? "" : "; charset=utf-8") == -1)
return (-1);
/* Set content length, if specified */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment