From 30d4924b31d9dc427311736d0f54dedafea9b170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Tue, 14 May 2024 10:33:15 +0200 Subject: [PATCH] feat: log CONNECT error response body --- src/resolve-protocol.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/resolve-protocol.ts b/src/resolve-protocol.ts index 6c8ed95..8410ab2 100644 --- a/src/resolve-protocol.ts +++ b/src/resolve-protocol.ts @@ -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; }