mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 12:12:12 +08:00
Update response_writer.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
1dca635ea2
commit
48e89fbe69
@ -109,8 +109,8 @@ func (w *responseWriter) Written() bool {
|
|||||||
|
|
||||||
// Hijack implements the http.Hijacker interface.
|
// Hijack implements the http.Hijacker interface.
|
||||||
func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||||
// Allow hijacking after headers are written (size == 0), but not after body data (size > 0)
|
// Allow hijacking before any data is written (size == -1) or after headers are written (size == 0),
|
||||||
// For compatibility with websocket libraries (e.g., github.com/coder/websocket)
|
// but not after body data is written (size > 0). For compatibility with websocket libraries (e.g., github.com/coder/websocket)
|
||||||
if w.size > 0 {
|
if w.size > 0 {
|
||||||
return nil, nil, errHijackAlreadyWritten
|
return nil, nil, errHijackAlreadyWritten
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user