Skip to content

Commit

Permalink
net/http: make TimeoutHandler's ResponseWriter implement Pusher
Browse files Browse the repository at this point in the history
Fixes golang#29193

Change-Id: I03088205e51036abbc861ab5b7d141327b0429ae
Reviewed-on: https://go-review.googlesource.com/c/154383
Reviewed-by: Brad Fitzpatrick <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
cuonglm authored and bradfitz committed Mar 2, 2019
1 parent 342764a commit 2889332
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/net/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2889332

Please sign in to comment.