v2rayA/v2rayA · error

response status error:%d

Error message

response status error:%d

What it means

gopeed's Resolve probes the download URL with a 'Range: bytes=0-0' request and requires HTTP 200 or 206 to extract file name, size, and range support. Any other status (403, 404, 302 handled poorly, 5xx, etc.) aborts with 'response status error:<code>'. It signals the server refused or could not serve the resource for probing.

Source

Thrown at service/pkg/util/gopeed/down.go:42

	Down(request *http.Request, filename string) error
}

// Resolve return the file response to be downloaded
func Resolve(request *Request) (*Response, error) {
	httpRequest, err := BuildHTTPRequest(request)
	if err != nil {
		return nil, err
	}
	// Use "Range" header to resolve
	httpRequest.Header.Add("Range", "bytes=0-0")
	httpClient := BuildHTTPClient()
	response, err := httpClient.Do(httpRequest)
	if err != nil {
		return nil, err
	}
	defer response.Body.Close()
	if response.StatusCode != 200 && response.StatusCode != 206 {
		return nil, fmt.Errorf("response status error:%d", response.StatusCode)
	}
	ret := &Response{}
	// Get file name by "Content-Disposition"
	contentDisposition := response.Header.Get("Content-Disposition")
	if contentDisposition != "" {
		_, params, _ := mime.ParseMediaType(contentDisposition)
		filename := params["filename"]
		if filename != "" {
			ret.Name = filename
		}
	}
	// Get file name by URL
	if ret.Name == "" {
		parse, err := url.Parse(httpRequest.URL.String())
		if err == nil {
			// e.g. /files/test.txt => test.txt
			ret.Name = subLastSlash(parse.Path)
		}

View on GitHub (pinned to 71e5442fc5)

Solutions

  1. Log/inspect the embedded status code and handle it: refresh the URL for 404, add auth for 401/403, back off for 429/5xx
  2. Add required headers (User-Agent, Referer, Authorization, cookies) to the request before calling Resolve
  3. Retry with exponential backoff for transient 5xx/429 responses
  4. Verify the download URL is current; use the redirect target if the link moved

Example fix

// before
_, err := gopeed.Resolve(req)
if err != nil { return err }
// after
resp, err := gopeed.Resolve(req)
if err != nil {
	if strings.Contains(err.Error(), "status error:4") {
		return fmt.Errorf("download link invalid or forbidden: %w", err)
	}
	return retryable(err) // backoff for 5xx/429
}
Defensive patterns

Strategy: retry

Validate before calling

probe, _ := http.Head(downloadURL)
if probe != nil && probe.StatusCode >= 400 {
	// refresh URL / add auth before calling gopeed
}

Try / catch

resp, err := gopeed.Resolve(req)
if err != nil {
	if m := statusRe.FindStringSubmatch(err.Error()); m != nil {
		code, _ := strconv.Atoi(m[1])
		if code == 429 || code >= 500 {
			return backoffRetry(req)
		}
		return fmt.Errorf("unrecoverable download failure (HTTP %d)", code)
	}
	return err
}

Prevention

When it happens

Trigger: Calling gopeed.Resolve (or Down, which calls it) on an http.Request whose response status is neither 200 nor 206 — e.g. expired/protected download link, missing auth headers/cookies, wrong URL, server not supporting the probe.

Common situations: Downloading core updates where the asset URL changed or was removed (404); GitHub/CDN rate limiting (403/429); hotlink protection requiring Referer; authenticated downloads without credentials; server errors during outage (5xx).

Related errors


AI-assisted analysis of v2rayA/v2rayA@71e5442fc5 (2026-09-05). Data as JSON: /api/errors/d4eb731f1ccab949. Report an issue: GitHub.