Skip to content

Commit

Permalink
return 499 when client closed requests only if LogRequests = true
Browse files Browse the repository at this point in the history
  • Loading branch information
nbari committed Oct 7, 2017
1 parent 72cf83a commit 0829095
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion responsewriter.go
Expand Up @@ -15,12 +15,20 @@ type ResponseWriter struct {

// NewResponseWriter returns ResponseWriter
func NewResponseWriter(w http.ResponseWriter, rid string) *ResponseWriter {
return &ResponseWriter{
rw := &ResponseWriter{
ResponseWriter: w,
requestID: rid,
start: time.Now(),
status: http.StatusOK,
}
if notify, ok := w.(http.CloseNotifier); ok {
notify := notify.CloseNotify()
go func() {
<-notify
rw.status = 499
}()
}
return rw
}

// Status provides an easy way to retrieve the status code
Expand Down

0 comments on commit 0829095

Please sign in to comment.