@@ 1,6 1,9 @@
package main
import (
+ "bufio"
+ "fmt"
+ "net"
"net/http"
)
@@ 10,6 13,28 @@ type interceptRW struct {
size int
}
+var (
+ _ http.Flusher = (*interceptRW)(nil)
+ _ http.Hijacker = (*interceptRW)(nil)
+)
+
+func (w *interceptRW) Unwrap() http.ResponseWriter {
+ return w.ResponseWriter
+}
+
+func (w *interceptRW) Flush() {
+ if f, ok := w.ResponseWriter.(http.Flusher); ok {
+ f.Flush()
+ }
+}
+
+func (w *interceptRW) Hijack() (net.Conn, *bufio.ReadWriter, error) {
+ if h, ok := w.ResponseWriter.(http.Hijacker); ok {
+ return h.Hijack()
+ }
+ return nil, nil, fmt.Errorf("connection does not support hijacking")
+}
+
func (w *interceptRW) WriteHeader(status int) {
w.status = status
w.ResponseWriter.WriteHeader(status)