{"record":{"id":"3c3c115047e1cccc","repo":"fish2018/pansou","slug":"post-w-3c3c11","errorCode":null,"errorMessage":"POST请求失败: %w","messagePattern":"POST请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/qupanshe/qupanshe.go","lineNumber":273,"sourceCode":"\t\t\t\tcookies := client.Jar.Cookies(u)\n\t\t\t\tfmt.Printf(\"[qupanshe] POST请求将发送 %d 个cookies:\\n\", len(cookies))\n\t\t\t\tfor i, cookie := range cookies {\n\t\t\t\t\tfmt.Printf(\"  Cookie[%d]: %s=%s\\n\", i, cookie.Name, cookie.Value)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// 不自动跟随重定向\n\tclient.CheckRedirect = func(req *http.Request, via []*http.Request) error {\n\t\treturn http.ErrUseLastResponse\n\t}\n\tdefer func() { client.CheckRedirect = nil }()\n\n\t// 带重试机制的请求\n\tresp, err := p.doRequestWithRetry(req, client)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"POST请求失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif DebugLog {\n\t\tfmt.Printf(\"[qupanshe] POST请求响应: status=%d\\n\", resp.StatusCode)\n\t\tfmt.Printf(\"[qupanshe] 响应头: %v\\n\", resp.Header)\n\t}\n\n\t// 从响应头获取Location\n\tlocation := resp.Header.Get(\"Location\")\n\tif DebugLog {\n\t\tfmt.Printf(\"[qupanshe] Location header: %s\\n\", location)\n\t}\n\n\t// 读取响应体用于调试（非重定向状态码时）\n\tif resp.StatusCode != 302 && resp.StatusCode != 301 && DebugLog {\n\t\tbody, readErr := io.ReadAll(resp.Body)\n\t\tif readErr == nil {","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/qupanshe/qupanshe.go#L255-L291","documentation":"postSearchRequest sends the POST via doRequestWithRetry (which follows redirects with a custom CheckRedirect policy). If every attempt fails — network error, DNS failure, timeout, TLS error — the last error is wrapped with this message. The underlying cause is in the wrapped error.","triggerScenarios":"The target site is unreachable: DNS resolution fails, connection refused/times out, TLS handshake fails, the 15s context deadline expires, or a proxy blocks the connection across all retry attempts.","commonSituations":"Site is down or has changed domain; no internet access / firewall blocks outbound HTTPS; corporate proxy required but unset; the site enforces TLS versions the client rejects; slow site exceeding the 15s timeout.","solutions":["Read the wrapped cause (%w) — it distinguishes DNS, timeout, TLS, and connection errors","Verify the site domain (BaseURL) is still correct and reachable (curl the URL)","Increase the 15s context timeout if the site is slow","Check proxy environment (HTTPS_PROXY) and system DNS","Retry later or add longer backoff in doRequestWithRetry"],"exampleFix":"// before\nresp, err := p.doRequestWithRetry(req, client)\nif err != nil {\n    return \"\", fmt.Errorf(\"POST请求失败: %w\", err)\n}\n// after\nvar netErr net.Error\nresp, err := p.doRequestWithRetry(req, client)\nif err != nil {\n    if errors.As(err, &netErr) && netErr.Timeout() {\n        return \"\", fmt.Errorf(\"POST请求超时(15s): %w\", err)\n    }\n    return \"\", fmt.Errorf(\"POST请求失败: %w\", err)\n}","handlingStrategy":"retry","validationCode":"// Pre-flight reachability check before the search flow\nresp, err := http.Head(BaseURL)\nif err != nil || resp.StatusCode >= 500 {\n    return fmt.Errorf(\"site unreachable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"_, err := plugin.Search(ctx, kw)\nvar netErr net.Error\nif errors.As(err, &netErr) && netErr.Timeout() {\n    // retry with longer timeout / later\n} else if err != nil {\n    // transport failure: check wrapped cause via errors.Unwrap\n}","preventionTips":["Distinguish timeout vs DNS vs TLS by inspecting the wrapped error","Use a sane timeout (increase 15s if the site is slow)","Configure proxy env vars if behind a corporate proxy","Add exponential backoff with a retry cap"],"tags":["network","http","timeout","retry"],"backgroundTag":"http-request-failed","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}