# File lib/ftw/protocol.rb, line 182 def read_http_body_chunked(&block) parser = HTTP::Parser.new # Fake fill-in the response we've already read into the parser. parser << to_s parser << CRLF parser.on_body = block done = false parser.on_message_complete = proc { done = true } while !done # will break on special conditions below # TODO(sissel): In JRuby, this read will sometimes hang for ever # because there's some wonkiness in IO.select on SSLSockets in JRuby. # Maybe we should fix it... data = @body.read offset = parser << data if offset != data.length raise "Parser did not consume all data read?" end end end