lib/excon/response.rb in excon-0.31.0 vs lib/excon/response.rb in excon-0.32.0

- old
+ new

@@ -26,21 +26,29 @@ @data[:remote_ip] = new_remote_ip end def remote_ip @data[:remote_ip] end + def local_port + @data[:local_port] + end + def local_address + @data[:local_address] + end def self.parse(socket, datum) # this will discard any trailing lines from the previous response if any. until match = /^HTTP\/\d+\.\d+\s(\d{3})\s/.match(socket.readline); end status = match[1].to_i datum[:response] = { - :body => '', - :headers => {}, - :status => status, - :remote_ip => socket.respond_to?(:remote_ip) && socket.remote_ip + :body => '', + :headers => {}, + :status => status, + :remote_ip => socket.respond_to?(:remote_ip) && socket.remote_ip, + :local_port => socket.respond_to?(:local_port) && socket.local_port, + :local_address => socket.respond_to?(:local_address) && socket.local_address } parse_headers(socket, datum) unless (['HEAD', 'CONNECT'].include?(datum[:method].to_s.upcase)) || NO_ENTITY.include?(datum[:response][:status]) @@ -124,13 +132,15 @@ def initialize(params={}) @data = { :body => '', :headers => {} }.merge(params) - @body = @data[:body] - @headers = @data[:headers] - @status = @data[:status] - @remote_ip = @data[:remote_ip] + @body = @data[:body] + @headers = @data[:headers] + @status = @data[:status] + @remote_ip = @data[:remote_ip] + @local_port = @data[:local_port] + @local_address = @data[:local_address] end def [](key) @data[key] end