Merge 44b40e45b451a38b6872bd0d81d6c5bd82fc2834 into 2a794cd0b0faa7d829291375b27a3467ea972b0d

This commit is contained in:
Griffin 2025-12-03 19:54:24 -08:00 committed by GitHub
commit ac8301c331
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -117,7 +117,11 @@ func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if w.size < 0 { if w.size < 0 {
w.size = 0 w.size = 0
} }
return w.ResponseWriter.(http.Hijacker).Hijack() hijacker, ok := w.ResponseWriter.(http.Hijacker)
if !ok {
return nil, nil, errors.New("response writer does not support Hijack")
}
return hijacker.Hijack()
} }
// CloseNotify implements the http.CloseNotifier interface. // CloseNotify implements the http.CloseNotifier interface.

View File

@ -113,10 +113,8 @@ func TestResponseWriterHijack(t *testing.T) {
writer.reset(testWriter) writer.reset(testWriter)
w := ResponseWriter(writer) w := ResponseWriter(writer)
assert.Panics(t, func() { _, _, err := w.Hijack()
_, _, err := w.Hijack() assert.Equal(t, "response writer does not support Hijack", err.Error())
require.NoError(t, err)
})
assert.True(t, w.Written()) assert.True(t, w.Written())
assert.Panics(t, func() { assert.Panics(t, func() {