MCPcopy
hub / github.com/minio/minio-go / do

Method do

api.go:617–655  ·  view source on GitHub ↗

do - execute http request.

(req *http.Request)

Source from the content-addressed store, hash-verified

615
616// do - execute http request.
617func (c *Client) do(req *http.Request) (resp *http.Response, err error) {
618 defer func() {
619 if IsNetworkOrHostDown(err, false) {
620 c.markOffline()
621 }
622 }()
623
624 resp, err = c.httpClient.Do(req)
625 if err != nil {
626 // Handle this specifically for now until future Golang versions fix this issue properly.
627 if urlErr, ok := err.(*url.Error); ok {
628 if strings.Contains(urlErr.Err.Error(), "EOF") {
629 return nil, &url.Error{
630 Op: urlErr.Op,
631 URL: urlErr.URL,
632 Err: errors.New("Connection closed by foreign host " + urlErr.URL + ". Retry again."),
633 }
634 }
635 }
636 return nil, err
637 }
638
639 // Response cannot be non-nil, report error if thats the case.
640 if resp == nil {
641 msg := "Response is empty. " + reportIssue
642 return nil, errInvalidArgument(msg)
643 }
644
645 // If trace is enabled, dump http request and response,
646 // except when the traceErrorsOnly enabled and the response's status code is ok
647 if c.isTraceEnabled && (!c.traceErrorsOnly || resp.StatusCode != http.StatusOK) {
648 err = c.dumpHTTP(req, resp)
649 if err != nil {
650 return nil, err
651 }
652 }
653
654 return resp, nil
655}
656
657// List of success status.
658var successStatus = set.CreateIntSet(

Callers 4

CreateSessionMethod · 0.95
executeMethodMethod · 0.95
PutObjectFanOutMethod · 0.95
getBucketLocationMethod · 0.95

Calls 7

markOfflineMethod · 0.95
dumpHTTPMethod · 0.95
IsNetworkOrHostDownFunction · 0.85
errInvalidArgumentFunction · 0.85
DoMethod · 0.80
ContainsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected