mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-22 00:59:11 +01:00
fix(reverseproxy): properly suppress http2.errStreamClosed
This commit is contained in:
@@ -33,6 +33,8 @@ import (
|
||||
U "github.com/yusing/go-proxy/internal/utils"
|
||||
"golang.org/x/net/http/httpguts"
|
||||
"golang.org/x/net/http2"
|
||||
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
// A ProxyRequest contains a request to be rewritten by a [ReverseProxy].
|
||||
@@ -169,6 +171,9 @@ func copyHeader(dst, src http.Header) {
|
||||
}
|
||||
}
|
||||
|
||||
//go:linkname errStreamClosed golang.org/x/net/http2.errStreamClosed
|
||||
var errStreamClosed error
|
||||
|
||||
func (p *ReverseProxy) errorHandler(rw http.ResponseWriter, r *http.Request, err error, writeHeader bool) {
|
||||
reqURL := r.Host + r.URL.Path
|
||||
switch {
|
||||
@@ -186,6 +191,9 @@ func (p *ReverseProxy) errorHandler(rw http.ResponseWriter, r *http.Request, err
|
||||
log.Err(err).Msg("underlying error")
|
||||
goto logged
|
||||
}
|
||||
if errors.Is(err, errStreamClosed) {
|
||||
goto logged
|
||||
}
|
||||
var h2Err http2.StreamError
|
||||
if errors.As(err, &h2Err) {
|
||||
// ignore these errors
|
||||
|
||||
Reference in New Issue
Block a user