migrate from http.Hijacker to http.NewResponseController

This commit is contained in:
WeidiDeng 2024-01-19 15:06:24 +08:00
parent 9c191f5301
commit 90e3711f5b
No known key found for this signature in database
GPG key ID: 25F87CE1741EC7CD

View file

@ -573,12 +573,7 @@ func serveHiddenPage(w http.ResponseWriter, authErr error) error {
// Hijacks the connection from ResponseWriter, writes the response and proxies data between targetConn
// and hijacked connection.
func serveHijack(w http.ResponseWriter, targetConn net.Conn) error {
hijacker, ok := w.(http.Hijacker)
if !ok {
return caddyhttp.Error(http.StatusInternalServerError,
fmt.Errorf("ResponseWriter does not implement http.Hijacker"))
}
clientConn, bufReader, err := hijacker.Hijack()
clientConn, bufReader, err := http.NewResponseController(w).Hijack()
if err != nil {
return caddyhttp.Error(http.StatusInternalServerError,
fmt.Errorf("hijack failed: %v", err))