Skip to content

Instantly share code, notes, and snippets.

@jfrazee
Last active August 3, 2017 21:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jfrazee/5400423 to your computer and use it in GitHub Desktop.
Fix for Ruby 2.0 tweetstream issue https://github.com/intridea/tweetstream/issues/117
--- a/lib/em-twitter/connection.rb
+++ b/lib/em-twitter/connection.rb
@@ -137,7 +137,7 @@ module EventMachine
protected
def handle_stream(data)
- @last_response << @decoder.decode(data)
+ @last_response << (@decoder ||= BaseDecoder.new).decode(data)
if @last_response.complete?
invoke_callback(@client.each_item_callback, @last_response.body)
@@ -149,17 +149,6 @@ module EventMachine
@response_code = @parser.status_code
@headers = headers
- @decoder = BaseDecoder.new
-
- # TODO: Complete gzip support
- # detect gzip encoding and use a decoder for response bodies
- # gzip needs to be detected with the Content-Encoding header
- # @decoder = if gzip?
- # GzipDecoder.new
- # else
- # BaseDecoder.new
- # end
-
# everything below here is error handling so return if we got a 200
if @response_code.to_i == 200
@network_reconnector.reset
@@ -301,6 +290,7 @@ module EventMachine
def reset_connection
@buffer = BufferedTokenizer.new("\r", MAX_LINE_LENGTH)
@parser = Http::Parser.new(self)
+ @parser.on_body = proc { |data| self.on_body(data) }
@last_response = Response.new
@response_code = 0
diff --git a/lib/em-twitter/version.rb b/lib/em-twitter/version.rb
index 137364c..30a4354 100644
--- a/lib/em-twitter/version.rb
+++ b/lib/em-twitter/version.rb
@@ -1,5 +1,5 @@
module EventMachine
module Twitter
- VERSION = "0.2.2" unless defined?(EventMachine::Twitter::VERSION)
+ VERSION = "0.2.2p1" unless defined?(EventMachine::Twitter::VERSION)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment