0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-13 20:09:36 +03:00

Add recover() to H2 server's flushWriter.Write()

Fixes https://github.com/XTLS/Xray-core/issues/1748
This commit is contained in:
RPRX
2023-03-08 14:06:20 +00:00
committed by GitHub
parent 4a0b45d1ff
commit 836e84b851
2 changed files with 10 additions and 5 deletions

View File

@ -51,6 +51,13 @@ func (fw flushWriter) Write(p []byte) (n int, err error) {
return 0, io.ErrClosedPipe
}
defer func() {
if recover() != nil {
fw.d.Close()
err = io.ErrClosedPipe
}
}()
n, err = fw.w.Write(p)
if f, ok := fw.w.(http.Flusher); ok && err == nil {
f.Flush()