forked from mirror/client_golang
Merge pull request #634 from prometheus/beorn7/promhttp
Add WriteHeader call to Flush
This commit is contained in:
commit
35ef65db67
|
@ -62,6 +62,8 @@ func (r *responseWriterDelegator) WriteHeader(code int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *responseWriterDelegator) Write(b []byte) (int, error) {
|
func (r *responseWriterDelegator) Write(b []byte) (int, error) {
|
||||||
|
// If applicable, call WriteHeader here so that observeWriteHeader is
|
||||||
|
// handled appropriately.
|
||||||
if !r.wroteHeader {
|
if !r.wroteHeader {
|
||||||
r.WriteHeader(http.StatusOK)
|
r.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
@ -82,12 +84,19 @@ func (d closeNotifierDelegator) CloseNotify() <-chan bool {
|
||||||
return d.ResponseWriter.(http.CloseNotifier).CloseNotify()
|
return d.ResponseWriter.(http.CloseNotifier).CloseNotify()
|
||||||
}
|
}
|
||||||
func (d flusherDelegator) Flush() {
|
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()
|
d.ResponseWriter.(http.Flusher).Flush()
|
||||||
}
|
}
|
||||||
func (d hijackerDelegator) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
func (d hijackerDelegator) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||||
return d.ResponseWriter.(http.Hijacker).Hijack()
|
return d.ResponseWriter.(http.Hijacker).Hijack()
|
||||||
}
|
}
|
||||||
func (d readerFromDelegator) ReadFrom(re io.Reader) (int64, error) {
|
func (d readerFromDelegator) ReadFrom(re io.Reader) (int64, error) {
|
||||||
|
// If applicable, call WriteHeader here so that observeWriteHeader is
|
||||||
|
// handled appropriately.
|
||||||
if !d.wroteHeader {
|
if !d.wroteHeader {
|
||||||
d.WriteHeader(http.StatusOK)
|
d.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue