Skip to content

Commit

Permalink
proxy: use errors.Is instead of string match (#2166)
Browse files Browse the repository at this point in the history
See golang/go#4373

Signed-off-by: Alexander Yastrebov <[email protected]>

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov authored Dec 10, 2022
1 parent c9260a4 commit fadff2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions proxy/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io"
"net"
Expand Down Expand Up @@ -215,8 +216,7 @@ func (p *upgradeProxy) dialBackend(req *http.Request) (net.Conn, error) {
func copyAsync(dir string, src io.Reader, dst io.Writer, done chan<- struct{}) {
go func() {
_, err := io.Copy(dst, src)
// net: errClosing not exported https://github.com/golang/go/issues/4373
if err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
if err != nil && !errors.Is(err, net.ErrClosed) {
log.Errorf("error copying data %s: %v", dir, err)
}
done <- struct{}{}
Expand Down

0 comments on commit fadff2e

Please sign in to comment.