mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
encode: flush status code when hijacked. (#5419)
This commit is contained in:
parent
94d41a9d86
commit
b3f0cea2c3
1 changed files with 14 additions and 0 deletions
|
@ -20,9 +20,11 @@
|
||||||
package encode
|
package encode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -212,6 +214,18 @@ func (rw *responseWriter) Flush() {
|
||||||
rw.HTTPInterfaces.Flush()
|
rw.HTTPInterfaces.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hijack implements http.Hijacker. It will flush status code if set. We don't track actual hijacked
|
||||||
|
// status assuming http middlewares will track its status.
|
||||||
|
func (rw *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||||
|
if !rw.wroteHeader {
|
||||||
|
if rw.statusCode != 0 {
|
||||||
|
rw.HTTPInterfaces.WriteHeader(rw.statusCode)
|
||||||
|
}
|
||||||
|
rw.wroteHeader = true
|
||||||
|
}
|
||||||
|
return rw.HTTPInterfaces.Hijack()
|
||||||
|
}
|
||||||
|
|
||||||
// Write writes to the response. If the response qualifies,
|
// Write writes to the response. If the response qualifies,
|
||||||
// it is encoded using the encoder, which is initialized
|
// it is encoded using the encoder, which is initialized
|
||||||
// if not done so already.
|
// if not done so already.
|
||||||
|
|
Loading…
Reference in a new issue