{"record":{"id":"a685f8304f4c63ab","repo":"apify/crawlee","slug":"the-http-method-connect-is-not-supported-by-the-go","errorCode":null,"errorMessage":"The HTTP method CONNECT is not supported by the GotScrapingHttpClient.","messagePattern":"The HTTP method CONNECT is not supported by the GotScrapingHttpClient\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/got-scraping-client/src/index.ts","lineNumber":41,"sourceCode":"        for (const [key, value] of Object.entries(headers)) {\n            if (key.startsWith(':') || value === undefined) continue;\n            if (Array.isArray(value)) {\n                for (const v of value) yield [key, v];\n            } else {\n                yield [key, value];\n            }\n        }\n    }\n\n    private parseHeaders(headers: Record<string, string | string[] | undefined>): Headers {\n        return new Headers([...this.iterateHeaders(headers)]);\n    }\n\n    override async fetch(request: Request, options?: RequestInit & CustomFetchOptions): Promise<Response> {\n        const { proxyUrl, redirect, ignoreTlsErrors } = options ?? {};\n\n        if (!this.validateRequest(request)) {\n            throw new Error(`The HTTP method CONNECT is not supported by the GotScrapingHttpClient.`);\n        }\n\n        const gotResult = await gotScraping({\n            url: request.url!,\n            method: request.method as Options['method'],\n            headers: Object.fromEntries(request.headers.entries()),\n            body: request.body ? Readable.fromWeb(request.body as any) : undefined,\n            proxyUrl,\n            signal: options?.signal ?? undefined,\n            followRedirect: redirect === 'follow',\n            ...(ignoreTlsErrors ? { https: { rejectUnauthorized: false } } : {}),\n        });\n\n        const responseHeaders = this.parseHeaders(gotResult.headers);\n\n        return new ResponseWithUrl(new Uint8Array(gotResult.rawBody), {\n            headers: responseHeaders,\n            status: gotResult.statusCode,","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/got-scraping-client/src/index.ts#L23-L59","documentation":"GotScrapingHttpClient does not implement the HTTP CONNECT method (used for tunneling, e.g. HTTPS proxies). validateRequest fails for CONNECT requests, so fetch() throws before any network call is made.","triggerScenarios":"Calling httpClient.fetch(new Request(url, { method: 'CONNECT' })) or route() with a request whose method is CONNECT against the GotScraping client.","commonSituations":"Building a generic proxy server on top of the HTTP client; forwarding arbitrary user requests (browsers issue CONNECT for HTTPS through proxies); generated code that passes methods through unfiltered.","solutions":["Use a different HTTP client that supports CONNECT for tunneling use cases","Restrict your routing layer to standard methods (GET/POST/PUT/DELETE/PATCH/HEAD/OPTIONS)","Handle CONNECT requests separately (e.g. via node's http/https tunneling) before they reach this client","Map CONNECT requests to a supported flow instead of proxying raw tunnels"],"exampleFix":"// before\nconst res = await gotClient.fetch(new Request(url, { method: 'CONNECT' })); // throws\n// after\nif (request.method === 'CONNECT') {\n  return handleConnectTunnel(request); // separate tunneling implementation\n}\nconst res = await gotClient.fetch(request);","handlingStrategy":"validation","validationCode":"if (request.method === 'CONNECT') {\n  throw new Error('CONNECT is not supported by GotScrapingHttpClient; use a tunneling client');\n}","typeGuard":"const isSupportedMethod = (m) => ['GET','POST','PUT','DELETE','PATCH','HEAD','OPTIONS'].includes(m?.toUpperCase());","tryCatchPattern":"try {\n  return await gotClient.fetch(request);\n} catch (err) {\n  if (/CONNECT is not supported/.test(String(err))) {\n    return handleWithTunnelingClient(request);\n  }\n  throw err;\n}","preventionTips":["Filter CONNECT requests out before dispatching to GotScrapingHttpClient","Use a dedicated proxy/tunneling layer for CONNECT traffic","Validate request methods at your routing boundary"],"tags":["http","unsupported-method","got-scraping"],"backgroundTag":"unsupported-http-method","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}