From 3edb2ed2b121d4b81af0afba38146b33cce97626 Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Sat, 12 Nov 2016 17:57:17 -0800 Subject: [PATCH] Add charset to UTF-8 for content type headers --- server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index 23b4152..ca3689a 100644 --- a/server.go +++ b/server.go @@ -98,7 +98,7 @@ func (s *Server) sendResponse(resp http.ResponseWriter, ip *IP, responseType res s.logger.Printf("Request from %s %s\n", ip.version, ip) var body []byte - var contentType = "text/plain" + var contentType = "text/plain; charset=utf-8" var err error switch responseType { @@ -108,7 +108,7 @@ func (s *Server) sendResponse(resp http.ResponseWriter, ip *IP, responseType res if marshalErr != nil { err = errors.Wrap(marshalErr, "could not marshal json") } - contentType = "application/json" + contentType = "application/json; charset=utf-8" body = jsonBody case htmlResponse: @@ -117,7 +117,7 @@ func (s *Server) sendResponse(resp http.ResponseWriter, ip *IP, responseType res if exeErr != nil { err = errors.Wrap(exeErr, "could not get html") } - contentType = "text/html" + contentType = "text/html; charset=utf-8" body = buffer.Bytes() default: