hashicorp / hashicorp/consul

http.Response.Body of api response is sometimes not read completely and connections are not reused.

Open
#3,316 1 comment 0 reactions 0 assignees View on GitHub
theme/api type/bug
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
2d 6h
Merged PRs (30d)
43

Description

### `consul version` for both Client and Server
Client: `0.8.5`
Server: `0.8.5`

### Operating system and Environment details
Go 1.8.3

### Description of the Issue (and unexpected/desired result)
The consul api client in golang does not consume the complete body of the response received from the consul server. Because of that, the http (keep alive) connection can not be re-used and will be closed.

### Reproduction steps
Use a connection that prints a message, each time a new connection is created, then call some endpoints, like `client.Health().Service("my-service", "", true, nil)`:
```golang
api.NewClient(&api.Config{
Address: consulAddress,
HttpClient: &http.Client{
Transport: &http.Transport{
Proxy: nil,
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
log.Infof("Dialing %s %s", network, address)
return dial(ctx, network, address)
},
ResponseHeaderTimeout: 90 * time.Second,
},
},
})
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.