-
Notifications
You must be signed in to change notification settings - Fork 251
Is there a way to get the CONNECT response headers? #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ok, sounds good. I'm thinking there could be two different APIs for this. We could do one, or both: Option 1Event on the const req = https.get(url, { agent });
req.on('proxyConnect', (connect) => {
console.log(connect.statusCode);
// 200
console.log(connect.headers);
// {
// connection: 'keep-alive'
// }
}); This API feels more intuitive to me, but might be problematic for wrappers around the Option 2Event on the Agent instance: const agent = new HttpsProxyAgent(proxyUrl);
agent.on('proxyConnect', (connect, req) => {
}); Same |
Thanks for the quick response! |
Part of #153. I'd like to also emit this event on the `agent` instance itself, but this is currently blocked by DefinitelyTyped/DefinitelyTyped#65408.
Part of #153. I'd like to also emit this event on the `agent` instance itself, but this is currently blocked by DefinitelyTyped/DefinitelyTyped#65408.
Thanks! You're awesome. |
This is a re-open of issue #119. I've looked at the newest code and this is still not possible.
Hi,
Is there a way to get the response headers that are sent back to the client by the proxy in response to the CONNECT method?
Typically these headers return metadata associated with the proxy itself and how it may be acting.
These are distinct of course from response headers to the actual proxied request issued subsequent to the CONNECT.
If you debug into the source, it appears to capture these headers here:
https://github.com/TooTallNate/proxy-agents/blob/main/packages/https-proxy-agent/src/parse-proxy-response.ts#L53
And then returns them internally in a Promise here:
https://github.com/TooTallNate/proxy-agents/blob/main/packages/https-proxy-agent/src/index.ts#L133
So that
buffered
variable holds the headers returned by the proxy server after CONNECT is issued.Would be really nice if this was exposed via an API and/or callback event.
if the proxy itself adds headers (to responses from the target host), then those would show up and be accessible like any other response headers and pass right through this agent.
But in my case I am using a proxy that does not do that, and passed some important headers only in its own CONNECT response.
Thanks
The text was updated successfully, but these errors were encountered: