mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user