mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3216 from yichengq/cancel-err
client: return context canceled error correctly
This commit is contained in:
commit
b9c6b64d61
@ -392,11 +392,9 @@ func (c *simpleHTTPClient) Do(ctx context.Context, act httpAction) (*http.Respon
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
err = resp.Body.Close()
|
resp.Body.Close()
|
||||||
<-done
|
<-done
|
||||||
if err == nil {
|
return nil, nil, ctx.Err()
|
||||||
err = ctx.Err()
|
|
||||||
}
|
|
||||||
case <-done:
|
case <-done:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,8 +257,8 @@ func TestSimpleHTTPClientDoCancelContextResponseBodyClosedWithBlockingBody(t *te
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
_, _, err := c.Do(ctx, &fakeAction{})
|
_, _, err := c.Do(ctx, &fakeAction{})
|
||||||
if err == nil {
|
if err != context.Canceled {
|
||||||
t.Fatalf("expected non-nil error, got nil")
|
t.Fatalf("expected %+v, got %+v", context.Canceled, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !body.closed {
|
if !body.closed {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user