mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-22 01:12:16 +08:00
Flush any written headers on Hijack
Closes #2108 Will make gin compatible with nhooyr.io/websocket.
This commit is contained in:
parent
db9174ae0c
commit
b63e300299
@ -101,6 +101,13 @@ 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) {
|
||||||
|
// If the header was written but we did not write it to the
|
||||||
|
// underlying response writer yet, we need to.
|
||||||
|
// This matches the behaviour of net/http's Hijacker.
|
||||||
|
// See #2108.
|
||||||
|
if w.status != 0 && !w.Written() {
|
||||||
|
w.WriteHeaderNow()
|
||||||
|
}
|
||||||
if w.size < 0 {
|
if w.size < 0 {
|
||||||
w.size = 0
|
w.size = 0
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user