fish2018/pansou · error
GET请求失败
Error message
GET请求失败: %w
What it means
getFormhash wraps a failure from client.Do when executing the GET request to the homepage. This is a transport-level failure: the request never completed with an HTTP response, so formhash extraction cannot proceed.
Solutions
- Test connectivity to BaseURL (curl/ping) from the same host
- Check DNS and proxy environment variables (HTTP_PROXY/HTTPS_PROXY)
- Increase the 15s context timeout if the site is slow
- Verify TLS: update system CA pool or handle certificate issues
- Add retry with backoff for transient network errors
Example fix
// before ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) // after ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
Defensive patterns
Strategy: retry
Validate before calling
// pre-flight: confirm host reachable
conn, err := net.DialTimeout("tcp", host+":80", 3*time.Second)
if err != nil { /* skip search: network down */ } else { conn.Close() } Try / catch
if err != nil && strings.Contains(err.Error(), "GET请求失败") {
var ne net.Error
if errors.As(err, &ne) && ne.Timeout() {
// retry with longer timeout
}
} Prevention
- Check proxy env vars are correct for the host
- Use timeouts generous enough for slow sites
- Add retry with exponential backoff
- Monitor DNS/TLS health on the deployment host
When it happens
Trigger: client.Do(req) returns an error during Step 1: DNS failure, connection refused/reset, TLS errors, request timeout (15s context or client.Timeout), or proxy failures.
Common situations: Site unreachable or offline, DNS misconfiguration, corporate proxy/firewall blocking, TLS certificate problems, or slow site exceeding the 15-second context timeout.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/e8b94fef66fb23fb.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/qupanshe/qupanshe.go:158
// getFormhash 从首页获取真实的formhash值
func (p *QupanshePlugin) getFormhash(client *http.Client) (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", BaseURL, nil)
if err != nil {
return "", fmt.Errorf("创建GET请求失败: %w", err)
}
p.setRequestHeaders(req)
if DebugLog {
fmt.Printf("[qupanshe] 请求首页获取formhash: %s\n", BaseURL)
}
resp, err := client.Do(req)
if err != nil {
return "", fmt.Errorf("GET请求失败: %w", err)
}
defer resp.Body.Close()
// 调试:显示从首页获取的cookies
if DebugLog && client.Jar != nil {
if u, _ := url.Parse(BaseURL); u != nil {
cookies := client.Jar.Cookies(u)
fmt.Printf("[qupanshe] 从首页获取到 %d 个cookies:\n", len(cookies))
for i, cookie := range cookies {
fmt.Printf(" Cookie[%d]: %s=%s\n", i, cookie.Name, cookie.Value)
}
}
}
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("首页请求返回状态码: %d", resp.StatusCode)
}
View on GitHub (pinned to beaa561337)