1
0
mirror of https://github.com/golang/go synced 2024-11-23 06:00:08 -07:00

net/http: make TimeoutHandler's ResponseWriter implement Pusher

Fixes #29193

Change-Id: I03088205e51036abbc861ab5b7d141327b0429ae
Reviewed-on: https://go-review.googlesource.com/c/154383
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
LE Manh Cuong 2018-12-17 11:06:30 +07:00 committed by Brad Fitzpatrick
parent 342764a216
commit 2889332edf

View File

@ -3223,6 +3223,25 @@ type timeoutWriter struct {
code int
}
var _ Pusher = (*timeoutWriter)(nil)
var _ Flusher = (*timeoutWriter)(nil)
// Push implements the Pusher interface.
func (tw *timeoutWriter) Push(target string, opts *PushOptions) error {
if pusher, ok := tw.w.(Pusher); ok {
return pusher.Push(target, opts)
}
return ErrNotSupported
}
// Flush implements the Flusher interface.
func (tw *timeoutWriter) Flush() {
f, ok := tw.w.(Flusher)
if ok {
f.Flush()
}
}
func (tw *timeoutWriter) Header() Header { return tw.h }
func (tw *timeoutWriter) Write(p []byte) (int, error) {