TUN-3490: Make sure OriginClient implementation doesn't write after Proxy return

This commit is contained in:
cthuang
2020-10-30 11:41:14 +00:00
parent d5769519b2
commit 543169c893
4 changed files with 79 additions and 7 deletions

View File

@@ -190,6 +190,13 @@ func (rp *http2RespWriter) Read(p []byte) (n int, err error) {
}
func (rp *http2RespWriter) Write(p []byte) (n int, err error) {
defer func() {
// Implementer of OriginClient should make sure it doesn't write to the connection after Proxy returns
// Register a recover routine just in case.
if r := recover(); r != nil {
println("Recover from http2 response writer panic, error", r)
}
}()
n, err = rp.w.Write(p)
if err == nil && rp.shouldFlush {
rp.flusher.Flush()