Skip to content

Commit

Permalink
Merge pull request #43 from cpunion/hijacker
Browse files Browse the repository at this point in the history
http: nocache, tracer implements http.Hijacker
  • Loading branch information
xushiwei authored Aug 27, 2023
2 parents c0ab963 + 56544ff commit fa669d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions http/nocache/nocache.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package nocache

import (
"bufio"
"net"
"net/http"
)

Expand All @@ -19,3 +21,7 @@ func New(h http.Handler) http.Handler {
h.ServeHTTP(&respWriter{w}, r)
})
}

func (p *respWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return p.ResponseWriter.(http.Hijacker).Hijack()
}
6 changes: 6 additions & 0 deletions http/tracer/tracer.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package tracer

import (
"bufio"
"log"
"net"
"net/http"
"time"
)
Expand All @@ -27,6 +29,10 @@ func (p *teeResponseWriter) WriteHeader(statusCode int) {
p.b.WriteHeader(statusCode)
}

func (p *teeResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return p.a.(http.Hijacker).Hijack()
}

func Tee(a, b http.ResponseWriter) http.ResponseWriter {
return &teeResponseWriter{a, b}
}
Expand Down

0 comments on commit fa669d7

Please sign in to comment.