This reverts CL 533119.
Reason for revert: the test fails frequently, see #65287.
Fixes #65287.
Change-Id: I5bf2ee2b7ce435608ff76b892da261c0a4a189bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/558916
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cherry Mui <cherryyz@google.com>
reqBodyClosed = true
if !deadline.IsZero() && didTimeout() {
err = &httpError{
- err: fmt.Errorf("%w (Client.Timeout exceeded while awaiting headers)", err),
+ err: err.Error() + " (Client.Timeout exceeded while awaiting headers)",
timeout: true,
}
}
}
if b.reqDidTimeout() {
err = &httpError{
- err: fmt.Errorf("%w (Client.Timeout exceeded or context cancellation while reading body)", err),
+ err: err.Error() + " (Client.Timeout or context cancellation while reading body)",
timeout: true,
}
}
t.Fatalf("server got body %q, want %q", gotBody, content)
}
}
-
-func TestClientTimeoutReturnsContextDeadlineExceeded(t *testing.T) {
- run(t, testClientTimeoutReturnsContextDeadlineExceeded)
-}
-func testClientTimeoutReturnsContextDeadlineExceeded(t *testing.T, mode testMode) {
- doneCh := make(chan struct{})
- defer close(doneCh)
- cst := newClientServerTest(t, mode, HandlerFunc(func(w ResponseWriter, r *Request) {
- <-doneCh
- w.WriteHeader(200)
- }))
- // check that, upon exceeding Client.Timeout, the returned error is context.DeadlineExceeded.
- cst.c.Timeout = 1 * time.Millisecond
- req, _ := NewRequest("GET", cst.ts.URL, nil)
- _, err := cst.c.Do(req)
- if !errors.Is(err, context.DeadlineExceeded) {
- t.Fatalf("expected context.DeadlineExceeded, got %v", err)
- }
-}
}
type httpError struct {
- err error
+ err string
timeout bool
}
-func (e *httpError) Error() string { return e.err.Error() }
-func (e *httpError) Timeout() bool { return e.timeout }
-func (e *httpError) Temporary() bool { return true }
-func (e *httpError) Is(target error) bool { return errors.Is(e.err, target) }
-func (e *httpError) Unwrap() error { return e.err }
+func (e *httpError) Error() string { return e.err }
+func (e *httpError) Timeout() bool { return e.timeout }
+func (e *httpError) Temporary() bool { return true }
-var errTimeout error = &httpError{err: errors.New("net/http: timeout awaiting response headers"), timeout: true}
+var errTimeout error = &httpError{err: "net/http: timeout awaiting response headers", timeout: true}
// errRequestCanceled is set to be identical to the one from h2 to facilitate
// testing.