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 proxy headers, add support for the https proxy #144

Closed
wants to merge 4 commits into from

Conversation

theArina
Copy link

@theArina theArina commented Jul 29, 2021

Sorry for the mess though.
#121, #47 related.

@mnmkng
Copy link
Member

mnmkng commented Jul 29, 2021

Could you clean this up a bit please? There are a lot of unrelated changes in this PR caused by old commits. I have no idea what this PR would do when it has 900 changed lines in the diff.

@theArina
Copy link
Author

@mnmkng, sure.

@theArina
Copy link
Author

@mnmkng, hey, should I've even made a PR into this branch ? I now realise that it was updated long ago. And I was pulling changes from master.

@mnmkng
Copy link
Member

mnmkng commented Jul 31, 2021

Yeah, you're right. I missed it. Please make the PR against master, not develop. Thanks.

@theArina theArina changed the base branch from develop to master July 31, 2021 09:53
@theArina
Copy link
Author

@mnmkng, here you go!

@jancurn
Copy link
Member

jancurn commented Aug 2, 2021

@theArina thanks for your PR and the cleanup. However, there are still zero comments explaining what your changes do and what they are good for, and zero new unit tests for those changes. Also, I don't think it makes sense to add one more dependency "rimraf" just to enable "npm clean" command, that's just too wasteful.

@B4nan
Copy link
Member

B4nan commented Aug 2, 2021

Also, I don't think it makes sense to add one more dependency "rimraf" just to enable "npm clean" command, that's just too wasteful.

It depends - if we want to make this repository windows friendly, we can't use just rm (that's the point of rimraf, being platform independent). But it should be a dev dependency.

Granted, this is not related to the PR itself and would be better done separately.

@theArina
Copy link
Author

theArina commented Aug 2, 2021

I'll see what I can do with the comments and stuff.
It's just at first we made changes for the personal usage, but I thought someone else might also need this stuff.

@jancurn
Copy link
Member

jancurn commented Aug 2, 2021

@theArina I totally understand and are grateful for your help, we just require a certain standard for this library, as it's used quite a bit, including our own production systems.

const requestUrl = new URL(this.srcRequest.url);
const hostname = `${requestUrl.hostname}:${requestUrl.port || '80'}`;

let payload = `CONNECT ${hostname} HTTP/1.1\r\n`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Using the CONNECT protocol is unnecessary. This is just a regular web proxy.

this.trgRequest = http.request(reqOpts);

const fn = reqOpts.protocol === 'https:' ? https.request : http.request;
this.trgRequest = fn(reqOpts); 

and it should work.

@szmarczak
Copy link
Contributor

HTTPS proxy support should be now possible via replacing

if (handlerOpts.upstreamProxyUrlParsed.protocol !== 'http:') {

with

const { protocol } = handlerOpts.upstreamProxyUrlParsed;
if (protocol !== 'http:' && protocol !== 'https:') { 

@szmarczak szmarczak closed this Oct 18, 2021
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.

5 participants