Class: FPM::Fry::StreamParser::Instance

Inherits:
Excon::Middleware::Base
  • Object
show all
Defined in:
lib/fpm/fry/stream_parser.rb

Instance Method Summary collapse

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
# File 'lib/fpm/fry/stream_parser.rb', line 15

def response_call(datum)
  if datum[:response]
    # probably mocked
    if datum[:response][:body]
      headers = datum[:response][:headers]
      fake_socket = StringIO.new(datum[:response][:body])
      parse_response_data(fake_socket, headers)
    end
  else
    socket, headers = extract_socket_and_headers(datum)
    parse_response_data(socket, headers)
  end
  @stack.response_call(datum)
end