Skip to content

Commit 23fe1e3

Browse files
authoredJul 10, 2023
[https-proxy-agent] Slice the headers when parsing proxy server response (#212)
Fixes #207.
1 parent b75b5fd commit 23fe1e3

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed
 

‎.changeset/gentle-panthers-stare.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'https-proxy-agent': patch
3+
---
4+
5+
Correct the header parsing logic to stop before the response content to avoid generating an exception.

‎packages/https-proxy-agent/src/parse-proxy-response.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function parseProxyResponse(
6363
return;
6464
}
6565

66-
const headerParts = buffered.toString('ascii').split('\r\n');
66+
const headerParts = buffered.slice(0,endOfHeaders).toString('ascii').split('\r\n');
6767
const firstLine = headerParts.shift();
6868
if (!firstLine) {
6969
socket.destroy();

‎packages/proxy/src/proxy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,5 +462,5 @@ function requestAuthorization(
462462
'Proxy-Authenticate': 'Basic realm="' + realm + '"',
463463
};
464464
res.writeHead(407, headers);
465-
res.end();
465+
res.end('Proxy authorization required');
466466
}

1 commit comments

Comments
 (1)

vercel[bot] commented on Jul 10, 2023

@vercel[bot]
Please sign in to comment.