3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-11 06:29:29 +01:00

fix (*http.Server).Serve() exiting on ErrBadProxyLine

anything other than a (net.Error) with Temporary() == true
is treated as a fatal error that causes the http server to exit
This commit is contained in:
Shivaram Lingamneni 2020-09-16 06:12:27 -04:00
parent 36ea93cc9d
commit 0073b98505

View File

@ -21,8 +21,24 @@ const (
maxProxyLineLen = 107
)
// XXX implement net.Error with a Temporary() method that returns true;
// otherwise, ErrBadProxyLine will cause (*http.Server).Serve() to exit
type proxyLineError struct{}
func (p *proxyLineError) Error() string {
return "invalid PROXY line"
}
func (p *proxyLineError) Timeout() bool {
return false
}
func (p *proxyLineError) Temporary() bool {
return true
}
var (
ErrBadProxyLine = errors.New("invalid PROXY line")
ErrBadProxyLine error = &proxyLineError{}
// TODO(golang/go#4373): replace this with the stdlib ErrNetClosing
ErrNetClosing = errors.New("use of closed network connection")
)