Class: RDKit::HTTPParser
Instance Method Summary collapse
- #feed(data) ⇒ Object
- #gets ⇒ Object
-
#initialize ⇒ HTTPParser
constructor
A new instance of HTTPParser.
Constructor Details
#initialize ⇒ HTTPParser
Returns a new instance of HTTPParser.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rdkit/http_parser.rb', line 5 def initialize @parser = HTTP::Parser.new @responses = [] # https://github.com/tmm1/http_parser.rb @body = nil @parser. = proc do end @parser.on_headers_complete = proc do # p @parser.http_method # p @parser.request_url # p @parser.headers if (length = @parser.headers['Content-Length']) && length.to_i > 0 @body = '' else @responses << [@parser.http_method.downcase + "|" + @parser.request_url, nil] end end @parser.on_body = proc do |chunk| @body << chunk end @parser. = proc do # Headers and body is all parsed if @body @responses << [@parser.http_method.downcase + "|" + @parser.request_url, @body] @body = nil end end end |