MCPcopy
hub / github.com/moby/moby / sendRequest

Method sendRequest

client/request.go:107–122  ·  view source on GitHub ↗
(ctx context.Context, method, path string, query url.Values, body io.Reader, headers http.Header)

Source from the content-addressed store, hash-verified

105}
106
107func (cli *Client) sendRequest(ctx context.Context, method, path string, query url.Values, body io.Reader, headers http.Header) (*http.Response, error) {
108 req, err := cli.buildRequest(ctx, method, cli.getAPIPath(ctx, path, query), body, headers)
109 if err != nil {
110 return nil, err
111 }
112
113 resp, err := cli.doRequest(req)
114 if err != nil {
115 // Failed to connect or context error.
116 return resp, err
117 }
118
119 // Successfully made a request; return the response and handle any
120 // API HTTP response errors.
121 return resp, checkResponseErr(resp)
122}
123
124// doRequest sends an HTTP request and returns an HTTP response. It is a
125// wrapper around [http.Client.Do] with extra handling to decorate errors.

Callers 9

headMethod · 0.95
getMethod · 0.95
postMethod · 0.95
postRawMethod · 0.95
putRawMethod · 0.95
deleteMethod · 0.95
TestSetHostHeaderFunction · 0.80
TestCanceledContextFunction · 0.80

Calls 4

buildRequestMethod · 0.95
getAPIPathMethod · 0.95
doRequestMethod · 0.95
checkResponseErrFunction · 0.85

Tested by 3

TestSetHostHeaderFunction · 0.64
TestCanceledContextFunction · 0.64