You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goroutine responsible for the ResponseWriter exits. A 'better' way would be to trigger the work, block in the handler, write the work to a buffer, and then io.Copy(buf, w) to write it out back in the handler. Set a timeout to prevent the HTTP connection from timing out on the client side.
beego
func (output*BeegoOutput) Body(content []byte) error {
varencodingstringvarbuf=&bytes.Buffer{}
ifoutput.EnableGzip {
encoding=ParseEncoding(output.Context.Request)
}
ifb, n, _:=WriteBody(encoding, buf, content); b {
output.Header("Content-Encoding", n)
output.Header("Content-Length", strconv.Itoa(buf.Len()))
} else {
output.Header("Content-Length", strconv.Itoa(len(content)))
}
// Write status code if it has been set manually// Set it to 0 afterwards to prevent "multiple response.WriteHeader calls"ifoutput.Status!=0 {
output.Context.ResponseWriter.WriteHeader(output.Status)
output.Status=0
} else {
output.Context.ResponseWriter.Started=true
}
io.Copy(output.Context.ResponseWriter, buf)
returnnil
}
The text was updated successfully, but these errors were encountered:
问题及现象
不是每次都报错,我观察了下,是render里边的性能不够高
看了beego的源码,再结合stackoverflow上搜索到的回答https://stackoverflow.com/questions/29664720/golang-map-of-http-responsewriters
就是这个问题了。
The goroutine responsible for the ResponseWriter exits. A 'better' way would be to trigger the work, block in the handler, write the work to a buffer, and then io.Copy(buf, w) to write it out back in the handler. Set a timeout to prevent the HTTP connection from timing out on the client side.
beego
The text was updated successfully, but these errors were encountered: