Created
September 27, 2011 17:35
-
-
Save steeve/1245699 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EM.run do | |
conn = EventMachine::HttpRequest.new("http://url/to/big/xml") | |
conn.use EventMachine::Middleware::OAuth, OAuthConfig | |
read_io, write_io = IO.pipe | |
writer = EM.attach(write_io) | |
EventMachine.defer do | |
Zlib::GzipReader.new(read_io).each_line do |line| | |
puts line | |
end | |
end | |
http = conn.get(:redirects => 1, :head => {"Accept-Encoding" => "gzip"}, :decoding => false) | |
http.stream do |chunk| | |
writer.send_data(chunk) | |
end | |
http.callback do | |
write_io.close | |
EM.stop | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment