Skip to content

Instantly share code, notes, and snippets.

@neilmiddleton
Created June 24, 2013 18:35
Show Gist options
  • Save neilmiddleton/5852346 to your computer and use it in GitHub Desktop.
Save neilmiddleton/5852346 to your computer and use it in GitHub Desktop.
EventMachine.run do
EventMachine::PeriodicTimer.new(15) { out << "\0" }
http = EventMachine::HttpRequest.new(url, keepalive: true, connection_timeout: 0, inactivity_timeout: 0).get
buffer = ""
http.stream do |chunk|
buffer << chunk
while line = buffer.slice!(/.+\n/)
puts line
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment