MCPcopy Index your code
hub / github.com/chainreactors/EvilProxy / get

Method get

internal/pluginstore/github.go:138–171  ·  view source on GitHub ↗
(ctx context.Context, requestURL string, accept string, kind string, maxSize int64)

Source from the content-addressed store, hash-verified

136}
137
138func (c Client) get(ctx context.Context, requestURL string, accept string, kind string, maxSize int64) ([]byte, error) {
139 currentURL := strings.TrimSpace(requestURL)
140 for redirects := 0; ; redirects++ {
141 if errURL := validatePluginStoreRequestURL(c.Auth, currentURL, kind); errURL != nil {
142 return nil, errURL
143 }
144 headers := http.Header{
145 "Accept": []string{accept},
146 "User-Agent": []string{c.userAgent()},
147 }
148 if errAuth := applyPluginStoreAuth(headers, c.Auth, currentURL, kind); errAuth != nil {
149 return nil, errAuth
150 }
151 resp, errDo := pluginStoreGetNoRedirect(ctx, c.httpClient(), currentURL, headers)
152 if errDo != nil {
153 return nil, errDo
154 }
155 if pluginStoreRedirectStatus(resp.StatusCode) {
156 nextURL, errRedirect := pluginStoreRedirectURL(resp, currentURL)
157 if errClose := resp.Body.Close(); errClose != nil {
158 log.WithError(errClose).Debug("failed to close plugin store redirect body")
159 }
160 if errRedirect != nil {
161 return nil, errRedirect
162 }
163 if redirects >= maxPluginStoreRedirects {
164 return nil, fmt.Errorf("stopped after %d redirects", maxPluginStoreRedirects)
165 }
166 currentURL = nextURL
167 continue
168 }
169 return readPluginStoreResponse(resp, maxSize)
170 }
171}
172
173func (c Client) httpClient() HTTPDoer {
174 if c.HTTPClient != nil {

Callers 5

FetchRegistryMethod · 0.95
FetchLatestReleaseMethod · 0.95
FetchReleaseByTagMethod · 0.95
DownloadAssetMethod · 0.95
DownloadArtifactMethod · 0.95

Calls 9

userAgentMethod · 0.95
httpClientMethod · 0.95
applyPluginStoreAuthFunction · 0.85
pluginStoreGetNoRedirectFunction · 0.85
pluginStoreRedirectURLFunction · 0.85
readPluginStoreResponseFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected