Makis Maropoulos 2016-06-17 01:44:16 +03:00
parent 0d482508fc
commit 2942d384c4
2 changed files with 18 additions and 2 deletions

View File

@ -1157,8 +1157,8 @@ func (mux *serveMux) fireError(statusCode int, ctx *Context) {
if errHandler == nil { if errHandler == nil {
errHandler = HandlerFunc(func(ctx *Context) { errHandler = HandlerFunc(func(ctx *Context) {
ctx.ResetBody() ctx.ResetBody()
ctx.SetBodyString(statusText[statusCode])
ctx.SetStatusCode(statusCode) ctx.SetStatusCode(statusCode)
ctx.SetBodyString(statusText[statusCode])
}) })
mux.errorHandlers[statusCode] = errHandler mux.errorHandlers[statusCode] = errHandler
} }

View File

@ -98,9 +98,25 @@ func (c *connection) writer() {
return 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 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: case <-ticker.C:
if err := c.write(websocket.PingMessage, []byte{}); err != nil { if err := c.write(websocket.PingMessage, []byte{}); err != nil {