File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 3
3
package gzip
4
4
5
5
import (
6
+ "bufio"
6
7
"compress/gzip"
7
8
"fmt"
8
9
"io"
9
10
"io/ioutil"
11
+ "net"
10
12
"net/http"
11
13
"strings"
12
14
@@ -130,3 +132,12 @@ func (w *gzipResponseWriter) Write(b []byte) (int, error) {
130
132
n , err := w .Writer .Write (b )
131
133
return n , err
132
134
}
135
+
136
+ // Hijack implements http.Hijacker. It simply wraps the underlying
137
+ // ResponseWriter's Hijack method if there is one, or returns an error.
138
+ func (w * gzipResponseWriter ) Hijack () (net.Conn , * bufio.ReadWriter , error ) {
139
+ if hj , ok := w .ResponseWriter .(http.Hijacker ); ok {
140
+ return hj .Hijack ()
141
+ }
142
+ return nil , nil , fmt .Errorf ("not a Hijacker" )
143
+ }
Original file line number Diff line number Diff line change @@ -62,11 +62,11 @@ func (r *ResponseRecorder) Status() int {
62
62
return r .status
63
63
}
64
64
65
- // Hijacker is a wrapper of http.Hijacker underearth if any,
66
- // otherwise it just returns an error.
65
+ // Hijack implements http.Hijacker. It simply wraps the underlying
66
+ // ResponseWriter's Hijack method if there is one, or returns an error.
67
67
func (r * ResponseRecorder ) Hijack () (net.Conn , * bufio.ReadWriter , error ) {
68
68
if hj , ok := r .ResponseWriter .(http.Hijacker ); ok {
69
69
return hj .Hijack ()
70
70
}
71
- return nil , nil , errors .New ("I'm not a Hijacker" )
71
+ return nil , nil , errors .New ("not a Hijacker" )
72
72
}
You can’t perform that action at this time.
0 commit comments