-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http_stream deprecation and examples #154
Comments
Wondering the same 👍 |
+1 |
Same. +1 |
The following would be a way to do streaming with Net::HTTP, although twitter now requires oauth for authentication so the twitter example wouldn't work as it currently stands anyway. require 'yajl'
require 'net/http'
def object_parsed(obj)
puts obj.inspect
end
uri = URI("http://#{username}:#{password}@stream.twitter.com/spritzer.json")
request = Net::HTTP::Get.new(uri.request_uri)
Net::HTTP.start(uri.host, uri.port) do |http|
http.request request do |response|
parser = Yajl::Parser.new()
parser.on_parse_complete = method(:object_parsed)
response.read_body do |chunk|
parser << chunk
end
end
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If http_stream is going to be deprecated in 2.0 (generating a warning) what's the preferred implementation of the current:
Would it be possible to update the README with the new code? Thanks
The text was updated successfully, but these errors were encountered: