add http hijack methods (#555)
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package security
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"bufio"
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// A WithCodeResponseWriter is a helper to delay sealing a http.ResponseWriter on writing code.
|
||||
type WithCodeResponseWriter struct {
|
||||
@@ -20,6 +24,12 @@ func (w *WithCodeResponseWriter) Header() http.Header {
|
||||
return w.Writer.Header()
|
||||
}
|
||||
|
||||
// Hijack implements the http.Hijacker interface.
|
||||
// This expands the Response to fulfill http.Hijacker if the underlying http.ResponseWriter supports it.
|
||||
func (w *WithCodeResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
return w.Writer.(http.Hijacker).Hijack()
|
||||
}
|
||||
|
||||
// Write writes bytes into w.
|
||||
func (w *WithCodeResponseWriter) Write(bytes []byte) (int, error) {
|
||||
return w.Writer.Write(bytes)
|
||||
|
||||
Reference in New Issue
Block a user