Skip to content
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

Add support for proxyRequestOptions #72

Merged
merged 2 commits into from
Oct 7, 2022

Conversation

mbargiel
Copy link
Contributor

This PR adds a new property to the constructor options, proxyRequestOptions, which allows callers to provide options for the
CONNECT request made against the proxy. There are various reasons to do this:

  • A custom ca may need to be passed to the proxy connection but not the upstream connection (or vice versa) and the ca value is not known at launch or can change over time, preventing the use of NODE_EXTRA_CA_CERTS as a viable alternative because that environment variable is only used by Node during startup
  • Specific proxy headers may need to be sent which differ from the upstream request; for instance, Proxy-Authentication should be sent only to the proxy and Authorization should only be sent to the upstream server.

Implements #69
Note: this PR introduces a merge conflict with #71. Whichever lands first will require a manual merge before the other can land.

@mbargiel
Copy link
Contributor Author

Hi @delvedor ! I see you reviewed #81 which is practically the same as this PR (with subtle differences, and this one has tests) but not this one. Is there anything missing to this one?

Copy link
Owner

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Can you update the requestOption object to allow adding other custom options, such as the one described in #69?

Edit: I've missed a line in the review, the changes are good.
Can you update the types and the README as well?

Thanks!

@mbargiel
Copy link
Contributor Author

@delvedor Will do! Expect an update within a day or two.

@mbargiel
Copy link
Contributor Author

mbargiel commented Sep 28, 2022

@delvedor See a112371. Please note that I defined a single type for the proxyRequestOptions of both agent types because the proxy options and upstream protocol are orthogonal: for instance, you may need to pass custom TLS connect options to a proxy agent of either types HttpProxyAgent or HttpsProxyAgent, since either can be used over an HTTPS proxy connection.

EDIT: Sorry for the force-pushes, I realized the new interface was misnamed. I think I found a relevant name in the end, but I'm open to renaming it if needed.

Copy link
Owner

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@delvedor delvedor merged commit 3848d23 into delvedor:main Oct 7, 2022
@delvedor
Copy link
Owner

delvedor commented Oct 7, 2022

Released in v1.1.0, thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants