]> Cypherpunks.ru repositories - gostls13.git/commitdiff
net/http: let ErrNotSupported match errors.ErrUnsupported
authorIan Lance Taylor <iant@golang.org>
Wed, 10 May 2023 19:47:06 +0000 (12:47 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 10 May 2023 20:13:04 +0000 (20:13 +0000)
For #41198

Change-Id: Ibb030e94618a1f594cfd98ddea214ad7a88d2e73
Reviewed-on: https://go-review.googlesource.com/c/go/+/494122
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

api/next/41198.txt
src/net/http/request.go
src/net/http/request_test.go

index 6f83b18d42da335222325018c01fe4b7bad3f274..31996e6d2a1d96845f33f555cebaed1967f44b6c 100644 (file)
@@ -1 +1,2 @@
 pkg errors, var ErrUnsupported error #41198
+pkg net/http, method (*ProtocolError) Is(error) bool #41198
index a45c9e3d18e16a74a5bbb8b78de077d71042aa43..4e9190493c735a790048c483e834a42582ae4778 100644 (file)
@@ -48,6 +48,11 @@ type ProtocolError struct {
 
 func (pe *ProtocolError) Error() string { return pe.ErrorString }
 
+// Is lets http.ErrNotSupported match errors.ErrUnsupported.
+func (pe *ProtocolError) Is(err error) bool {
+       return pe == ErrNotSupported && err == errors.ErrUnsupported
+}
+
 var (
        // ErrNotSupported indicates that a feature is not supported.
        //
index 76c8790f1675bf229026bbb42ec9d006e6984b72..78b968f23cfb61954cb71863b623a3a817d7c55e 100644 (file)
@@ -10,6 +10,7 @@ import (
        "context"
        "crypto/rand"
        "encoding/base64"
+       "errors"
        "fmt"
        "io"
        "math"
@@ -1388,3 +1389,9 @@ func runFileAndServerBenchmarks(b *testing.B, mode testMode, f *os.File, n int64
                b.SetBytes(n)
        }
 }
+
+func TestErrNotSupported(t *testing.T) {
+       if !errors.Is(ErrNotSupported, errors.ErrUnsupported) {
+               t.Error("errors.Is(ErrNotSupported, errors.ErrUnsupported) failed")
+       }
+}