TooTallNate / node-pac-proxy-agent

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

Fetch of an https resource failed #3

Closed dogawaf closed 9 years ago

dogawaf commented 9 years ago

Hi

I encounter a weird behavior using a PAC file, and I wonder to know if pac-proxy-agent would be the cause.

I have to request a resource on a https endpoint: https://www.example.com/foo.png. But the proxy server send back a response in HTML, saying that the remote server is not available. When I am inspecting the error message returned by the proxy, I can read that the resource that the proxy tried to fetch is at http://www.example.com:443/foo.png.

Is pac-proxy-agent responsible for the rewriting from https to http + port 443?

Cheers

tehdeadone commented 9 years ago

I think I've encountered the same problem. My final url is https:// and if I enable debug I see this trace (it includes some trace from my own app) if I use pac-proxy-agent:

  pac-proxy-agent loading PAC file: "http://proxy/proxy.pac" +0ms
  pac-proxy-agent got stream.Readable instance for URI +10ms
  pac-proxy-agent read 6412 byte PAC file from URI +3ms
  pac-proxy-agent creating new proxy resolver instance +0ms
  pac-proxy-agent url: "http://demo.stwc.s3group.com:443/api/v1/login", host: "d
emo.stwc.s3group.com" +222ms
  pac-proxy-agent using proxy: "PROXY avproxylan.dublin.s3group.com:8080" +4ms
[2015-01-09 10:56:31.241] [INFO] snmpAgent -   http-proxy-agent creating new Htt
pProxyAgent instance: {"protocol":"http:","slashes":true,"auth":null,"host":"avp
roxylan.dublin.s3group.com:8080","port":"8080","hostname":"avproxylan.dublin.s3g
roup.com","hash":null,"search":null,"query":null,"pathname":"/","path":"/","href
":"http://avproxylan.dublin.s3group.com:8080/"} +0ms
[2015-01-09 10:56:31.242] [INFO] snmpAgent -   http-proxy-agent regenerating sto
red HTTP header string for request +1ms
[2015-01-09 10:56:31.243] [INFO] snmpAgent -   http-proxy-agent patching connect
ion write() output buffer with updated header +1ms
[2015-01-09 10:56:31.243] [INFO] snmpAgent -   http-proxy-agent output buffer: [
"POST http://demo.stwc.s3group.com:443/api/v1/login HTTP/1.1\r\nhost: demo.stwc.
s3group.com:443\r\naccept: application/json\r\ncontent-type: application/json\r\
ncontent-length: 50\r\nConnection: close\r\n\r\n",[123,34,117,115,101,114,110,97
,109,101,34,58,34,83,116,111,114,109,84,101,115,116,85,115,101,114,34,44,34,112,
97,115,115,119,111,114,100,34,58,34,66,114,117,88,54,54,80,97,34,125]] +0ms
[2015-01-09 10:56:31.267] [ERROR] snmpAgent - Failed to login (400)

However, because it's a https:// url, it should be resolving to https-proxy-agent instance. If I use proxy-agent module and use the http:// proxy url (from my proxy.pac), it will resolve to a https-proxy-agent agent correctly.

TooTallNate commented 9 years ago

I think I need more complete example code to reproduce this.

tehdeadone commented 9 years ago

I've tried to reproduce the problem with the latest version of pac-proxy-agent and proxy-agent and I can't. It seems to work properly in resolving the https address now

TooTallNate commented 9 years ago

Thanks for getting back to me. Closing this issue then!

dogawaf commented 9 years ago

Hi. I can't test this behavior anymore because the app which use Pac proxy agent has evolved and not contact any proxy now... But, cool to read that news ;)