{"record":{"id":"58f5ea7f05737ed1","repo":"fish2018/pansou","slug":"http-d-58f5ea","errorCode":null,"errorMessage":"获取预登录会话失败: HTTP %d","messagePattern":"获取预登录会话失败: HTTP (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/panlian/panlian.go","lineNumber":1088,"sourceCode":"\n\t// 站点登录只认预先由公开接口建立的 PHPSESSID。\n\tctx, cancel := context.WithTimeout(context.Background(), RequestTimeout)\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, DefaultBaseURL+\"/api/get_types.php\", nil)\n\tif err != nil {\n\t\tcancel()\n\t\treturn \"\", nil, err\n\t}\n\tp.setPanlianHeaders(req, \"\", DefaultBaseURL+\"/all-videos.php\")\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tcancel()\n\t\treturn \"\", nil, err\n\t}\n\tio.Copy(io.Discard, resp.Body)\n\tresp.Body.Close()\n\tcancel()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", nil, fmt.Errorf(\"获取预登录会话失败: HTTP %d\", resp.StatusCode)\n\t}\n\tbaseURL, _ := url.Parse(DefaultBaseURL)\n\tpreCookie := cookiesToString(jar.Cookies(baseURL))\n\n\tform := url.Values{}\n\tform.Set(\"username\", username)\n\tform.Set(\"password\", password)\n\tif remember {\n\t\tform.Set(\"remember\", \"on\")\n\t}\n\n\tctx, cancel = context.WithTimeout(context.Background(), RequestTimeout)\n\treq, err = http.NewRequestWithContext(ctx, http.MethodPost, DefaultBaseURL+\"/api/login.php\", strings.NewReader(form.Encode()))\n\tif err != nil {\n\t\tcancel()\n\t\treturn \"\", nil, err\n\t}\n\tp.setPanlianHeaders(req, preCookie, DefaultBaseURL+\"/pages/login.php\")","sourceCodeStart":1070,"sourceCodeEnd":1106,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/panlian/panlian.go#L1070-L1106","documentation":"doLogin first issues a GET to the panlian base URL to establish a pre-login session/cookie jar. If that request returns a non-200 status code, this error is thrown with the actual HTTP status embedded.","triggerScenarios":"The initial GET to DefaultBaseURL returns e.g. 403 (WAF/anti-bot), 502/503 (backend down), 30x not followed, or 429 rate limit.","commonSituations":"Panlian site temporarily down or under maintenance; request blocked by anti-bot protection because of missing/suspicious headers; corporate proxy returning errors.","solutions":["Check whether the panlian site is reachable in a browser / currently under maintenance","Retry with backoff; 5xx are usually transient","Send browser-like headers (User-Agent, Accept) on the pre-login GET to avoid WAF blocks","Check proxy/firewall settings if a corporate proxy is in the path"],"exampleFix":"// before\nresp, err := client.Get(DefaultBaseURL)\nif resp.StatusCode != http.StatusOK {\n    return \"\", nil, fmt.Errorf(\"获取预登录会话失败: HTTP %d\", resp.StatusCode)\n}\n// after\nreq, _ := http.NewRequest(http.MethodGet, DefaultBaseURL, nil)\nreq.Header.Set(\"User-Agent\", userAgent)\nreq.Header.Set(\"Accept\", \"text/html\")\nresp, err := client.Do(req)\nif err != nil { return \"\", nil, err }\nif resp.StatusCode != http.StatusOK {\n    return \"\", nil, fmt.Errorf(\"获取预登录会话失败: HTTP %d\", resp.StatusCode)\n}","handlingStrategy":"retry","validationCode":"u, err := url.Parse(DefaultBaseURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return errors.New(\"invalid panlian base URL\")\n}","typeGuard":null,"tryCatchPattern":"var resp *http.Response\nvar err error\nfor attempt := 0; attempt < 3; attempt++ {\n    resp, err = client.Get(DefaultBaseURL)\n    if err == nil && resp.StatusCode == 200 { break }\n    time.Sleep(time.Duration(attempt+1) * time.Second)\n}","preventionTips":["Send browser-like headers (User-Agent, Accept) on the pre-login GET","Retry transient 5xx with exponential backoff","Monitor the panlian site's availability before scheduled logins"],"tags":["http","network","login","go"],"backgroundTag":"http-error-response","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"}