TooTallNate / node-pac-proxy-agent

A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
59 stars 57 forks source link

Figure out an API for the fallback proxy servers #1

Closed TooTallNate closed 4 years ago

TooTallNate commented 10 years ago

The FindProxyForURL() function is able to return multiple semi-colon delimited values ("PROXY 1.2.3.4:3128; SOCKS 127.0.0.1:9050; DIRECT") which this agent is expected to try sequentially until the first working proxy is found.

Currently, only the first proxy server specified will ever be used, so I need to either figure out some API to step through the possibilities and then let the user handle it from there (i.e. let the user call http.request() multiple times upon failure, trying the next proxy down the list each time), but that's a PITA for the user.

Ideally, we could do some crazy hacks and hijack the "error" event on the http.Request instance, and transparently try the next proxy server when an error occurs. We would have to tear down the hijacking machinery once the "response" event occurred… Kinda a crazy idea, but if I can pull it off cleanly and reliably then this would be the best UX.