igrigorik/em-http-request — Issue #165: Streaming on get not working
Author: joaodrp
Created: 2012-01-16 21:00:28+00:00
State: open

Hi,

I have a Goliath server which streams a binary file to client GET requests, it works well with both browser and curl. I'm trying to read that in the client side with em-http but its not working. With Net::HTTP it works perfectly.

Sorry if this is not a bug but cant find other answer. I'm doing it like in examples without success.

This works without problems, it shows me all chunks:

```ruby
require 'net/http'

url = 'http://0.0.0.0:9000/images/bc9b0602-5ebc-468c-a369-c52def31619e'

Net::HTTP.get_response(URI(url)) do |response|
response.read_body { |chunk| print chunk }
end
```

With em-http it doesn't work:

```ruby
require 'eventmachine'
require 'em-http'

url = 'http://0.0.0.0:9000/images/bc9b0602-5ebc-468c-a369-c52def31619e'

EM.run do
http = EventMachine::HttpRequest.new(url).get
http.stream { |chunk| print chunk }

http.callback do
p "Done", http.response
EM.stop
end

http.errback do
p "Error", http.response
EM.stop
end
end
```
The only output that it produces is this:

"Done"
""

Any tips? Perhaps its related with application/octet-stream content. Cant find an answer.