Skip to content

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

@surlyhacker

Description

@surlyhacker

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions