igrigorik / em-http-request

Asynchronous HTTP Client (EventMachine + Ruby)
1.22k stars 220 forks source link

Support for defining HTTP proxy via the $HTTP_PROXY (etc) env-var #306

Closed mexisme closed 7 years ago

mexisme commented 7 years ago

I would like to be able to use the $HTTP_PROXY (etc) env-vars to set the HTTP proxy, rather than setting it explicitly so that I don't have to work around gems like lita-flowdock -- which don't appear to have direct support for this, and probably rightly so.

Is there a preferred way to do this? Happy to raise a PR for it, myself.

Thanks

igrigorik commented 7 years ago

Looks like you're already well on the way.. 👍

On a first pass, what you have there looks pretty reasonable.

mexisme commented 7 years ago

On a first pass, what you have there looks pretty reasonable.

Thanks!

FYI: have been doing some real-world tests with Lita+Flowdock via mitmproxy and weirdly having trouble getting the server to transmit data back.

Slowly debugging it...

mexisme commented 7 years ago

FYI: have been doing some real-world tests with Lita+Flowdock via mitmproxy and weirdly having trouble getting the server to transmit data back.

Slowly debugging it...

So, as far as I can tell it's purely down to the Proxy(s) I'm working with not piping/forwarding the Flowdock SSE data correctly, by default -- i.e. buffering on the way through. When I set my [local] test Proxy to TCP-Forward, it works perfectly.

Not sure if this is something that can be mitigated in em-http-request or em-socksify, @igrigorik, but I suspect it's "working as designed".

igrigorik commented 7 years ago

So, as far as I can tell it's purely down to the Proxy(s) I'm working with not piping/forwarding the Flowdock SSE data correctly, by default -- i.e. buffering on the way through.

This is not uncommon.. Many proxies buffer responses, which totally breaks SSE. There is nothing we can do to fix that from the client side.

mexisme commented 7 years ago

So, as far as I can tell it's purely down to the Proxy(s) I'm working with not piping/forwarding the Flowdock SSE data correctly, by default -- i.e. buffering on the way through. This is not uncommon.. Many proxies buffer responses, which totally breaks SSE. There is nothing we can do to fix that from the client side.

This is what my digging seemed to say, too. Very frustrating! Thanks for the confirmation.