diff options
| author | Marcel van Lohuizen <mpvl@golang.org> | 2019-02-08 17:50:36 +0100 |
|---|---|---|
| committer | Marcel van Lohuizen <mpvl@golang.org> | 2019-02-27 18:24:06 +0000 |
| commit | b34c5f0cb46d77c3929fc2b37e86f811c4d32377 (patch) | |
| tree | f10e637248c0117af9ef4a52d80c32bb296c3834 /src | |
| parent | 36b09f334f4d6ca96573b275118bd45db80f3727 (diff) | |
| download | go-b34c5f0cb46d77c3929fc2b37e86f811c4d32377.tar.xz | |
net/http: remove use of DeepEqual for testing errors
Comparing errors using DeepEqual breaks if frame information
is added as proposed in Issue #29934.
Updates #29934.
Change-Id: I4ef076e262109a9d6f5b18846129df2535611d71
Reviewed-on: https://go-review.googlesource.com/c/162178
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/net/http/clientserver_test.go | 2 | ||||
| -rw-r--r-- | src/net/http/transport.go | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/net/http/clientserver_test.go b/src/net/http/clientserver_test.go index 465bae1478..d61d77839d 100644 --- a/src/net/http/clientserver_test.go +++ b/src/net/http/clientserver_test.go @@ -560,7 +560,7 @@ func testCancelRequestMidBody(t *testing.T, h2 bool) { if all != "Hello" { t.Errorf("Read %q (%q + %q); want Hello", all, firstRead, rest) } - if !reflect.DeepEqual(err, ExportErrRequestCanceled) { + if err != ExportErrRequestCanceled { t.Errorf("ReadAll error = %v; want %v", err, ExportErrRequestCanceled) } } diff --git a/src/net/http/transport.go b/src/net/http/transport.go index a8c5efe6aa..bb9657f4ee 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -2073,7 +2073,10 @@ func (e *httpError) Timeout() bool { return e.timeout } func (e *httpError) Temporary() bool { return true } var errTimeout error = &httpError{err: "net/http: timeout awaiting response headers", timeout: true} -var errRequestCanceled = errors.New("net/http: request canceled") + +// errRequestCanceled is set to be identical to the one from h2 to facilitate +// testing. +var errRequestCanceled = http2errRequestCanceled var errRequestCanceledConn = errors.New("net/http: request canceled while waiting for connection") // TODO: unify? func nop() {} |
