]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: make TimeoutHandler's ResponseWriter implement Pusher
authorLE Manh Cuong <cuong.manhle.vn@gmail.com>
Mon, 17 Dec 2018 04:06:30 +0000 (11:06 +0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 2 Mar 2019 05:42:50 +0000 (05:42 +0000)
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>

src/net/http/server.go

index e68ec2f01efe991f57110cb4e426c1638db7d625..9ae0bbff14920c536d40730b7c4a27e830b19fce 100644 (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) {