Skip to content

Commit

Permalink
feat: log CONNECT error response body
Browse files Browse the repository at this point in the history
  • Loading branch information
barjin committed May 14, 2024
1 parent 6c6bf55 commit 30d4924
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/resolve-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ const connect = async (proxyUrl: string, options: tls.ConnectionOptions, callbac

request.once('connect', (response, socket, head) => {
if (response.statusCode !== 200 || head.length > 0) {
reject(new Error(`Proxy responded with ${response.statusCode} ${response.statusMessage}: ${head.length} bytes`));
reject(new Error(`Proxy responded with ${response.statusCode} ${response.statusMessage}: ${head.length} bytes.
Below is the first 100 bytes of the proxy response body:
${head.toString('utf8', 0, 100)}
`));
socket.destroy();
return;
}
Expand Down

0 comments on commit 30d4924

Please sign in to comment.