client: Client.Ping: re-use request when falling back to GET
Re-use the request, and change the method to GET instead of building a new request "from scratch". Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
87fff769f4
commit
58dc0fcd1e
1 changed files with 3 additions and 5 deletions
|
@ -37,11 +37,9 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) {
|
|||
return ping, err
|
||||
}
|
||||
|
||||
req, err = cli.buildRequest(http.MethodGet, path.Join(cli.basePath, "/_ping"), nil, nil)
|
||||
if err != nil {
|
||||
return ping, err
|
||||
}
|
||||
serverResp, err = cli.doRequest(ctx, req)
|
||||
// HEAD failed; fallback to GET.
|
||||
req.Method = http.MethodGet
|
||||
serverResp, err = cli.doRequest(req)
|
||||
defer ensureReaderClosed(serverResp)
|
||||
if err != nil {
|
||||
return ping, err
|
||||
|
|
Loading…
Add table
Reference in a new issue