| 222 | } |
| 223 | |
| 224 | func 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 | |
| 243 | func readPluginStoreResponse(resp *http.Response, maxSize int64) ([]byte, error) { |
| 244 | defer func() { |