TooTallNate / proxy-agents

Node.js HTTP Proxy Agents Monorepo
https://proxy-agents.n8.io
873 stars 228 forks source link

Is there a way to get the CONNECT response headers? #119

Closed surlyhacker closed 1 year ago

surlyhacker commented 3 years ago

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.

Thanks

jameshooddisc commented 2 years ago

Interesting question, did you find a solution for this?

Thanks!

surlyhacker commented 2 years ago

Well one way I just tried is to debug into the source, and it appears to capture these headers here: https://github.com/TooTallNate/node-https-proxy-agent/blob/master/src/parse-proxy-response.ts#L53 And then returns them internally in a Promise here: https://github.com/TooTallNate/node-https-proxy-agent/blob/master/src/agent.ts#L131 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.

jameshooddisc commented 2 years ago

Ah, thanks.

Yes, or adding them in final response headers like most of the proxies do.

surlyhacker commented 2 years ago

Well 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.

TooTallNate commented 1 year ago

This module has gone through a large refactor and modernization. I am closing this issue as a bit of house cleaning. If you feel that this issue still exists in the latest release, feel free to open a new issue.

surlyhacker commented 1 year ago

Reopened as #153