shithub: riscv

Download patch

ref: 3a3eb0434c3e5bc98b05a4a0a9752a1743b32512
parent: 8648e065346f354c354789fddf0e463bbeb529cb
author: Alex Musolino <alex@musolino.id.au>
date: Mon Jun 17 09:17:16 EDT 2019

rc-httpd: set charset=utf-8 for all text/* content types

--- a/rc/bin/rc-httpd/handlers/dir-index
+++ b/rc/bin/rc-httpd/handlers/dir-index
@@ -32,7 +32,7 @@
 do_log 200
 echo 'HTTP/1.1 200 OK'^$cr
 emit_extra_headers
-echo 'Content-type: text/html'^$cr
+echo 'Content-type: text/html; charset=utf-8'^$cr
 echo $cr
 echo '<html>
 <head>
--- a/rc/bin/rc-httpd/handlers/error
+++ b/rc/bin/rc-httpd/handlers/error
@@ -3,7 +3,7 @@
 fn do_error{
 	echo 'HTTP/1.1 '^$1^$cr
 	emit_extra_headers
-	echo 'Content-type: text/html'^$cr
+	echo 'Content-type: text/html; charset=utf-8'^$cr
 	echo $cr
 	echo '<html>
 <head>
--- a/rc/bin/rc-httpd/handlers/redirect
+++ b/rc/bin/rc-httpd/handlers/redirect
@@ -19,7 +19,7 @@
 }
 echo 'Location: ' ^ $2 ^ $cr
 emit_extra_headers
-echo 'Content-type: text/html'^$cr
+echo 'Content-type: text/html; charset=utf-8'^$cr
 echo $cr
 echo '<html><body>'
 if(~ $#3 0)
--- a/rc/bin/rc-httpd/handlers/serve-static
+++ b/rc/bin/rc-httpd/handlers/serve-static
@@ -23,7 +23,7 @@
 case *.css
         type=text/css
 case *.txt
-        type='text/plain; charset=utf-8'
+        type=text/plain
 case *.jpg *.jpeg
         type=image/jpeg
 case *.gif
@@ -33,6 +33,8 @@
 case *
         type=`{file -m $full_path}
 }
+if(~ $type text/*)
+	type=$type^'; charset=utf-8'
 max_age=3600	# 1 hour
 echo 'HTTP/1.1 200 OK'^$cr
 emit_extra_headers