MCPcopy Create free account
hub / github.com/containerd/containerd / RoundTrip

Method RoundTrip

core/remotes/docker/resolver.go:959–996  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

957}
958
959func (f *httpFallback) RoundTrip(r *http.Request) (*http.Response, error) {
960 f.mu.Lock()
961 fallback := f.host == r.URL.Host
962 f.mu.Unlock()
963
964 // only fall back if the same host had previously fell back
965 if !fallback {
966 resp, err := f.super.RoundTrip(r)
967 if !isTLSError(err) && !isPortError(err, r.URL.Host) {
968 return resp, err
969 }
970 }
971
972 plainHTTPUrl := *r.URL
973 plainHTTPUrl.Scheme = "http"
974
975 plainHTTPRequest := *r
976 plainHTTPRequest.URL = &plainHTTPUrl
977
978 if !fallback {
979 f.mu.Lock()
980 if f.host != r.URL.Host {
981 f.host = r.URL.Host
982 }
983 f.mu.Unlock()
984
985 // update body on the second attempt
986 if r.Body != nil && r.GetBody != nil {
987 body, err := r.GetBody()
988 if err != nil {
989 return nil, err
990 }
991 plainHTTPRequest.Body = body
992 }
993 }
994
995 return f.super.RoundTrip(&plainHTTPRequest)
996}
997
998func isTLSError(err error) bool {
999 if err == nil {

Callers

nothing calls this directly

Calls 4

isTLSErrorFunction · 0.85
isPortErrorFunction · 0.85
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected