5d531d3d by lw

fix jsonp, use Buffer

1 parent ea756b68
...@@ -227,10 +227,13 @@ func (c *Controller) ServeJsonp() { ...@@ -227,10 +227,13 @@ func (c *Controller) ServeJsonp() {
227 http.Error(c.Ctx.ResponseWriter, `"callback" parameter required`, http.StatusInternalServerError) 227 http.Error(c.Ctx.ResponseWriter, `"callback" parameter required`, http.StatusInternalServerError)
228 return 228 return
229 } 229 }
230 callback_content := fmt.Sprintf("%s(%s);\r\n", callback, string(content)) 230 callback_content := bytes.NewBufferString(callback)
231 c.Ctx.SetHeader("Content-Length", strconv.Itoa(len(callback_content)), true) 231 callback_content.WriteString("(")
232 c.Ctx.ResponseWriter.Header().Set("Content-Type", "application/jsonp;charset=UTF-8") 232 callback_content.Write(content)
233 c.Ctx.ResponseWriter.Write([]byte(callback_content)) 233 callback_content.WriteString(");\r\n")
234 c.Ctx.SetHeader("Content-Length", strconv.Itoa(callback_content.Len()), true)
235 c.Ctx.ResponseWriter.Header().Set("Content-Type", "application/json;charset=UTF-8")
236 c.Ctx.ResponseWriter.Write(callback_content.Bytes())
234 } 237 }
235 238
236 func (c *Controller) ServeXml() { 239 func (c *Controller) ServeXml() {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!