Skip to content

Commit

Permalink
Merge pull request #634 from prometheus/beorn7/promhttp
Browse files Browse the repository at this point in the history
Add WriteHeader call to Flush
  • Loading branch information
beorn7 committed Aug 20, 2019
2 parents 4efc3cc + ad58180 commit 35ef65d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions prometheus/promhttp/delegator.go
Expand Up @@ -62,6 +62,8 @@ func (r *responseWriterDelegator) WriteHeader(code int) {
}

func (r *responseWriterDelegator) Write(b []byte) (int, error) {
// If applicable, call WriteHeader here so that observeWriteHeader is
// handled appropriately.
if !r.wroteHeader {
r.WriteHeader(http.StatusOK)
}
Expand All @@ -82,12 +84,19 @@ func (d closeNotifierDelegator) CloseNotify() <-chan bool {
return d.ResponseWriter.(http.CloseNotifier).CloseNotify()
}
func (d flusherDelegator) Flush() {
// If applicable, call WriteHeader here so that observeWriteHeader is
// handled appropriately.
if !d.wroteHeader {
d.WriteHeader(http.StatusOK)
}
d.ResponseWriter.(http.Flusher).Flush()
}
func (d hijackerDelegator) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return d.ResponseWriter.(http.Hijacker).Hijack()
}
func (d readerFromDelegator) ReadFrom(re io.Reader) (int64, error) {
// If applicable, call WriteHeader here so that observeWriteHeader is
// handled appropriately.
if !d.wroteHeader {
d.WriteHeader(http.StatusOK)
}
Expand Down

0 comments on commit 35ef65d

Please sign in to comment.