Skip to content

Commit

Permalink
Fix for voloko#27 - 'Could not parse data entirely'
Browse files Browse the repository at this point in the history
The parser needs to be reset in case of reconnection, or you'll get a
HTTP::Parser::Error.
  • Loading branch information
mremond committed Dec 22, 2013
1 parent 27c53f0 commit 6c9934f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/twitter/json_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ def reset_state
@state = :init
@buffer = BufferedTokenizer.new("\r", MAX_LINE_LENGTH)
@stream = ''
end

def reset_parser
@parser = Http::Parser.new
@parser.on_headers_complete = method(:handle_headers_complete)
@parser.on_body = method(:receive_stream_data)
Expand Down Expand Up @@ -238,6 +240,8 @@ def receive_stream_data(data)
end

def send_request
reset_parser

data = []
request_uri = @options[:path]

Expand Down

0 comments on commit 6c9934f

Please sign in to comment.