Class: FPM::Fry::StreamParser::Instance
- Inherits:
-
Excon::Middleware::Base
- Object
- Excon::Middleware::Base
- FPM::Fry::StreamParser::Instance
- Defined in:
- lib/fpm/fry/stream_parser.rb
Instance Method Summary collapse
-
#initialize(stack, parser) ⇒ Instance
constructor
A new instance of Instance.
- #response_call(datum) ⇒ Object
Constructor Details
#initialize(stack, parser) ⇒ Instance
Returns a new instance of Instance.
10 11 12 13 |
# File 'lib/fpm/fry/stream_parser.rb', line 10 def initialize(stack, parser) super(stack) @parser = parser end |
Instance Method Details
#response_call(datum) ⇒ Object
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/fpm/fry/stream_parser.rb', line 15 def response_call(datum) if datum[:response] # probably mocked if datum[:response][:body] @parser.parse(StringIO.new(datum[:response][:body])) end return @stack.response_call(datum) else socket = datum[:connection].send(:socket) begin line = socket.readline match = /^HTTP\/\d+\.\d+\s(\d{3})\s/.match(line) end while !match status = match[1].to_i datum[:response] = { :body => '', :headers => Excon::Headers.new, :status => status, :remote_ip => socket.respond_to?(:remote_ip) && socket.remote_ip, } Excon::Response.parse_headers(socket, datum) @parser.parse(socket) return @stack.response_call(datum) end end |