@@ -2,6 +2,7 @@ package baa
22
33import (
44 "bufio"
5+ "errors"
56 "io"
67 "net"
78 "net/http"
@@ -69,14 +70,27 @@ func (r *Response) WriteHeader(code int) {
6970// buffered data to the client.
7071// See [http.Flusher](https://golang.org/pkg/net/http/#Flusher)
7172func (r * Response ) Flush () {
72- r .resp .(http.Flusher ).Flush ()
73+ if v , ok := r .resp .(http.Flusher ); ok {
74+ v .Flush ()
75+ }
76+ }
77+
78+ // Pusher is the interface implemented by ResponseWriters that support
79+ // HTTP/2 server push. For more background, see
80+ // https://tools.ietf.org/html/rfc7540#section-8.2.
81+ func (r * Response ) Pusher () (http.Pusher , bool ) {
82+ v , ok := r .resp .(http.Pusher )
83+ return v , ok
7384}
7485
7586// Hijack implements the http.Hijacker interface to allow an HTTP handler to
7687// take over the connection.
7788// See [http.Hijacker](https://golang.org/pkg/net/http/#Hijacker)
7889func (r * Response ) Hijack () (net.Conn , * bufio.ReadWriter , error ) {
79- return r .resp .(http.Hijacker ).Hijack ()
90+ if v , ok := r .resp .(http.Hijacker ); ok {
91+ return v .Hijack ()
92+ }
93+ return nil , nil , errors .New ("http.response denot implements the http.Hijacker" )
8094}
8195
8296// CloseNotify implements the http.CloseNotifier interface to allow detecting
0 commit comments