MSP-1470 implement Hijacker iface for ws proxy
This commit is contained in:
1 parent
0e51c54415
commit
35e9311cc7
1 file changed
+10
@@ -1,8 +1,10 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/integration-system/isp-kit/http/endpoint/buffer"
|
||||
@@ -20,6 +22,14 @@ type writerWrapper struct {
|
||||
statusCode int
|
||||
}
|
||||
|
||||
func (w *writerWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
upstream, ok := w.ResponseWriter.(http.Hijacker)
|
||||
if !ok {
|
||||
return nil, nil, errors.New("writerWrapper: upstream writer doesn't implement Hijack")
|
||||
}
|
||||
return upstream.Hijack()
|
||||
}
|
||||
|
||||
func (w *writerWrapper) StatusCode() int {
|
||||
if w.statusCode == 0 {
|
||||
return http.StatusOK
|
||||
|
||||
Reference in new issue
Block a user