-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build !go1.20 | ||
|
||
package websocket | ||
|
||
import ( | ||
"bufio" | ||
"net" | ||
"net/http" | ||
) | ||
|
||
func HijackResponse(_ *http.Request, w http.ResponseWriter) (net.Conn, *bufio.ReadWriter, error) { | ||
return http.NewResponseController(w).Hijack() | ||
Check failure on line 12 in server_utils.go GitHub Actions / test (1.18.x, ubuntu-latest)
Check failure on line 12 in server_utils.go GitHub Actions / build (1.18.x)
Check failure on line 12 in server_utils.go GitHub Actions / test (1.18.x, ubuntu-latest)
Check failure on line 12 in server_utils.go GitHub Actions / test (1.19.x, ubuntu-latest)
Check failure on line 12 in server_utils.go GitHub Actions / build (1.19.x)
Check failure on line 12 in server_utils.go GitHub Actions / test (1.18.x, macos-latest)
Check failure on line 12 in server_utils.go GitHub Actions / test (1.18.x, windows-latest)
Check failure on line 12 in server_utils.go GitHub Actions / test (1.19.x, ubuntu-latest)
Check failure on line 12 in server_utils.go GitHub Actions / test (1.19.x, macos-latest)
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build go1.20 | ||
|
||
package websocket | ||
|
||
import ( | ||
"bufio" | ||
"net" | ||
"net/http" | ||
) | ||
|
||
func HijackResponse(r *http.Request, w http.ResponseWriter) (net.Conn, *bufio.ReadWriter, error) { | ||
h, ok := w.(http.Hijacker) | ||
if !ok { | ||
return nil, nil, ErrResponseHijackUnsupported | ||
} | ||
|
||
var brw *bufio.ReadWriter | ||
netConn, brw, err := h.Hijack() | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
return netConn, brw, nil | ||
} |