{"record":{"id":"961bc71b193cfd48","repo":"ginuerzh/gost","slug":"s-961bc7","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"http.go","lineNumber":102,"sourceCode":"\t}\n\n\tif Debug {\n\t\tdump, _ := httputil.DumpRequest(req, false)\n\t\tlog.Log(string(dump))\n\t}\n\n\tresp, err := http.ReadResponse(bufio.NewReader(conn), req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif Debug {\n\t\tdump, _ := httputil.DumpResponse(resp, false)\n\t\tlog.Log(string(dump))\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"%s\", resp.Status)\n\t}\n\n\treturn conn, nil\n}\n\ntype httpHandler struct {\n\toptions *HandlerOptions\n}\n\n// HTTPHandler creates a server Handler for HTTP proxy server.\nfunc HTTPHandler(opts ...HandlerOption) Handler {\n\th := &httpHandler{}\n\th.Init(opts...)\n\treturn h\n}\n\nfunc (h *httpHandler) Init(options ...HandlerOption) {\n\tif h.options == nil {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/http.go#L84-L120","documentation":"The HTTP CONNECT tunnel was established at the transport level, but the proxy answered with a non-200 status code. The connector surfaces the raw HTTP status line (e.g. \"403 Forbidden\", \"502 Bad Gateway\") as the error.","triggerScenarios":"ConnectContext receives resp.StatusCode != http.StatusOK after sending the HTTP CONNECT request — proxy refuses the CONNECT (auth missing/wrong, target blocked, proxy overloaded, upstream failure).","commonSituations":"Corporate proxies rejecting CONNECT to non-443 ports; proxy requiring Proxy-Authorization credentials; upstream target unreachable so proxy returns 502/504; ACLs on the proxy denying the destination.","solutions":["Read resp.Status in the error to identify the code and act on it (401/407 → add credentials, 403 → fix proxy ACL, 5xx → check upstream).","Add correct proxy authentication (user:pass@host in the node address or Proxy-Authorization header).","Verify the target host:port is allowed by the proxy's policy; try a different target/port.","Test the proxy with curl -x proxy -I to confirm it accepts CONNECT independently of this library."],"exampleFix":"// before\nnode = \"http://proxy.corp:3128?tunnel=direct\" // proxy requires auth\n// after\nnode = \"http://user:pass@proxy.corp:3128\"","handlingStrategy":"try-catch","validationCode":"// pre-check proxy CONNECT support\ncmd := exec.Command(\"curl\", \"-x\", proxyURL, \"-I\", \"https://target:443\", \"--max-time\", \"10\")\nif err := cmd.Run(); err != nil { log.Println(\"proxy CONNECT pre-check failed\") }","typeGuard":null,"tryCatchPattern":"conn, err := connector.Connect(conn, \"tcp\", addr)\nif err != nil {\n    if strings.Contains(err.Error(), \"401\") || strings.Contains(err.Error(), \"407\") {\n        return fmt.Errorf(\"proxy auth required: %w\", err)\n    }\n    return err\n}","preventionTips":["Embed proxy credentials in the node address","Confirm destination ports are allowed by the proxy ACL","Test proxy independently with curl before deploying"],"tags":["network","http","proxy","connect"],"backgroundTag":"http-connect-refused","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}