MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / pluginStoreRedirectURL

Function pluginStoreRedirectURL

internal/pluginstore/github.go:224–241  ·  view source on GitHub ↗
(resp *http.Response, requestURL string)

Source from the content-addressed store, hash-verified

222}
223
224func pluginStoreRedirectURL(resp *http.Response, requestURL string) (string, error) {
225 location := strings.TrimSpace(resp.Header.Get("Location"))
226 if location == "" {
227 return "", fmt.Errorf("redirect missing Location header")
228 }
229 base, errBase := url.Parse(requestURL)
230 if errBase != nil {
231 return "", fmt.Errorf("parse redirect base: %w", errBase)
232 }
233 next, errNext := base.Parse(location)
234 if errNext != nil {
235 return "", fmt.Errorf("parse redirect location: %w", errNext)
236 }
237 if next.Scheme == "" || next.Host == "" {
238 return "", fmt.Errorf("redirect location is not absolute")
239 }
240 return next.String(), nil
241}
242
243func readPluginStoreResponse(resp *http.Response, maxSize int64) ([]byte, error) {
244 defer func() {

Callers 1

getMethod · 0.85

Calls 2

GetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected