voloko / twitter-stream

Twitter realtime API client
MIT License
233 stars 81 forks source link

Proxy support? #2

Closed bgreenlee closed 14 years ago

bgreenlee commented 14 years ago

It doesn't appear that twitter-stream and/or EventMachine supports http proxies. Is that right?

voloko commented 14 years ago

I think you can. By passing proxy ip address as a host parameter and sending stream.twitter.com into the Host: http header. Thought you have to add additional option to options hash.

But you have to manually update http://github.com/voloko/twitter-stream/blob/master/lib/twitter/json_stream.rb#L164

Share if you do the fork

http://github.com/voloko/twitter-stream/blob/master/lib/twitter/json_stream.rb#L164

bgreenlee commented 14 years ago

I tried that, but it's not working (our proxy is sending back 400 Bad Request). Looking at http://github.com/igrigorik/em-http-request, I think it's a bit more complicated than that. I think I'll see if I can get something working with em-http-request.

voloko commented 14 years ago

hmm. It looks like it does exactly the same thing with the request: http://github.com/igrigorik/em-http-request/blob/master/lib/em-http/request.rb#L61

Anyway, if you find the solution, let me know. It might be useful to add this to twitter-stream

bgreenlee commented 14 years ago

Not if you dig a bit deeper: http://github.com/igrigorik/em-http-request/blob/master/lib/em-http/client.rb#L210

voloko commented 14 years ago

I did. But the code you showing has nothing to do with the request. Its about response parsing.

bgreenlee commented 14 years ago

The problem turned out to be that proxies need to have the full url in the request, not just the path. Fixed: http://github.com/bgreenlee/twitter-stream/commit/6a06df789c070fa47f2313974b8d384ab0a8fab7