Skip to content

Commit 87b098f

Browse files
authored
Fix json charset bug (#14514)
1 parent f19da14 commit 87b098f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/context/context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interfa
330330
// PlainText render content as plain text
331331
func (ctx *Context) PlainText(status int, bs []byte) {
332332
ctx.Resp.WriteHeader(status)
333-
ctx.Resp.Header().Set("Content-Type", "text/plain;charset=utf8")
333+
ctx.Resp.Header().Set("Content-Type", "text/plain;charset=utf-8")
334334
if _, err := ctx.Resp.Write(bs); err != nil {
335335
ctx.ServerError("Render JSON failed", err)
336336
}
@@ -365,7 +365,7 @@ func (ctx *Context) Error(status int, contents ...string) {
365365

366366
// JSON render content as JSON
367367
func (ctx *Context) JSON(status int, content interface{}) {
368-
ctx.Resp.Header().Set("Content-Type", "application/json;charset=utf8")
368+
ctx.Resp.Header().Set("Content-Type", "application/json;charset=utf-8")
369369
ctx.Resp.WriteHeader(status)
370370
if err := json.NewEncoder(ctx.Resp).Encode(content); err != nil {
371371
ctx.ServerError("Render JSON failed", err)

0 commit comments

Comments
 (0)