greim / hoxy

Web-hacking proxy API for node
http://greim.github.io/hoxy/
MIT License
597 stars 97 forks source link

upstreamProxy authentication #79

Closed randunel closed 8 years ago

randunel commented 8 years ago

How can the proxy credentials be specified? Is proxy authentication supported?

greim commented 8 years ago

It's not supported at the moment, but PRs are definitely welcome :)

asharron commented 5 years ago

Hey! I want to add this feature, but I need some help.

What I would like to do is extend the upStream proxy from host:port to be able to support origin\Username:Password@Host:Port.

I see that the upstream proxy gets set here in the following code

    if (opts.upstreamProxy) {
      let proxy = opts.upstreamProxy
      if (!/^https?:\/\//.test(proxy)) {
        proxy = 'http://' + proxy
      }
      if (!/^https?:\/\/[^:]+:\d+$/.test(proxy)) {
        throw new Error(`invalid value for upstreamProxy: "${opts.upstreamProxy}"`)
      }
      this._upstreamProxy = proxy
    }

I want to edit this to add the support, but I'm not sure how to do that in a way that conforms with the way you have this project setup. Basically, I want to make sure I conform to your coding standards.

~~What I am confused about is the part where you are checking the regex and using the .test on it. Can you give me a short explanation of what this is doing? Is the .test actually doing a simple request to see if it can connect, or is it simply doing a regex matching pattern? Sorry for the confusion, its just that this seems a little cryptic to me.~~

Scratch the above. If I had actually googled before writing this I would have known that .test is a way to test a regex expression with a string passed in. Let me see if I can't add this support in.