mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
Try third to solve https://github.com/kataras/iris/issues/175#issuecomment-226634061
This commit is contained in:
parent
0d482508fc
commit
2942d384c4
2
http.go
2
http.go
|
@ -1157,8 +1157,8 @@ func (mux *serveMux) fireError(statusCode int, ctx *Context) {
|
|||
if errHandler == nil {
|
||||
errHandler = HandlerFunc(func(ctx *Context) {
|
||||
ctx.ResetBody()
|
||||
ctx.SetBodyString(statusText[statusCode])
|
||||
ctx.SetStatusCode(statusCode)
|
||||
ctx.SetBodyString(statusText[statusCode])
|
||||
})
|
||||
mux.errorHandlers[statusCode] = errHandler
|
||||
}
|
||||
|
|
|
@ -98,9 +98,25 @@ func (c *connection) writer() {
|
|||
return
|
||||
}
|
||||
|
||||
if err := c.write(websocket.TextMessage, msg); err != nil {
|
||||
c.underline.SetWriteDeadline(time.Now().Add(c.server.config.WriteTimeout))
|
||||
res, err := c.underline.NextWriter(websocket.TextMessage)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res.Write(msg)
|
||||
|
||||
n := len(c.send)
|
||||
for i := 0; i < n; i++ {
|
||||
res.Write(<-c.send)
|
||||
}
|
||||
|
||||
if err := res.Close(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// if err := c.write(websocket.TextMessage, msg); err != nil {
|
||||
// return
|
||||
// }
|
||||
|
||||
case <-ticker.C:
|
||||
if err := c.write(websocket.PingMessage, []byte{}); err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user