浏览代码

go-raw: add missing charset=utf-8 to fortune content type

kostya-sh 9 年之前
父节点
当前提交
ddf1531b24
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      frameworks/Go/go-raw/src/hello/hello.go

+ 2 - 2
frameworks/Go/go-raw/src/hello/hello.go

@@ -280,7 +280,7 @@ func fortuneHandler(w http.ResponseWriter, r *http.Request) {
 
 
 	sort.Sort(ByMessage{fortunes})
 	sort.Sort(ByMessage{fortunes})
 	w.Header().Set("Server", "Go")
 	w.Header().Set("Server", "Go")
-	w.Header().Set("Content-Type", "text/html")
+	w.Header().Set("Content-Type", "text/html; charset=utf-8")
 	if err := tmpl.Execute(w, fortunes); err != nil {
 	if err := tmpl.Execute(w, fortunes); err != nil {
 		http.Error(w, err.Error(), http.StatusInternalServerError)
 		http.Error(w, err.Error(), http.StatusInternalServerError)
 	}
 	}
@@ -297,7 +297,7 @@ func fortuneInterpolateHandler(w http.ResponseWriter, r *http.Request) {
 
 
 	sort.Sort(ByMessage{fortunes})
 	sort.Sort(ByMessage{fortunes})
 	w.Header().Set("Server", "Go")
 	w.Header().Set("Server", "Go")
-	w.Header().Set("Content-Type", "text/html")
+	w.Header().Set("Content-Type", "text/html; charset=utf-8")
 	if err := tmpl.Execute(w, fortunes); err != nil {
 	if err := tmpl.Execute(w, fortunes); err != nil {
 		http.Error(w, err.Error(), http.StatusInternalServerError)
 		http.Error(w, err.Error(), http.StatusInternalServerError)
 	}
 	}