lib/flexirest/request.rb in flexirest-1.3.31 vs lib/flexirest/request.rb in flexirest-1.3.32

- old
+ new

@@ -193,11 +193,11 @@ # Otherwise this callback is called after the parallel request block ends. response.on_complete do |response_env| if verbose? Flexirest::Logger.debug " Response" Flexirest::Logger.debug " << Status : #{response_env.status}" - (response_env.response_headers || response_env.try(:response).try(:headers)).each do |k,v| + response_env.response_headers.each do |k,v| Flexirest::Logger.debug " << #{k} : #{v}" end Flexirest::Logger.debug " << Body:\n#{response_env.body}" end @@ -498,12 +498,12 @@ object end def hal_response? - _, content_type = (@response.response_headers || @response.try(:response).try(:headers)).detect{|k,v| k.downcase == "content-type"} - faked_response = (@response.response_headers || @response.try(:response).try(:headers)).detect{|k,v| k.downcase == "x-arc-faked-response"} + _, content_type = @response.response_headers.detect{|k,v| k.downcase == "content-type"} + faked_response = @response.response_headers.detect{|k,v| k.downcase == "x-arc-faked-response"} if content_type && content_type.respond_to?(:each) content_type.each do |ct| return true if ct[%r{application\/hal\+json}i] return true if ct[%r{application\/json}i] end @@ -559,17 +559,15 @@ parent_name || name end def is_json_response? - headers = (@response.response_headers || @response.try(:response).try(:headers)) - headers['Content-Type'].nil? || headers['Content-Type'].include?('json') + @response.response_headers['Content-Type'].nil? || @response.response_headers['Content-Type'].include?('json') end def is_xml_response? - headers = (@response.response_headers || @response.try(:response).try(:headers)) - headers['Content-Type'].include?('xml') + @response.response_headers['Content-Type'].include?('xml') end def generate_new_object(options={}) if @response.body.is_a?(Array) || @response.body.is_a?(Hash) body = @response.body @@ -605,11 +603,11 @@ result << new_object(json_object, @overridden_name) end else result = new_object(body, @overridden_name) result._status = @response.status - result._headers = (@response.response_headers || @response.try(:response).try(:headers)) - result._etag = result._headers['ETag'] + result._headers = @response.response_headers + result._etag = @response.response_headers['ETag'] if !object_is_class? && options[:mutable] != false @object._copy_from(result) @object._clean! result = @object end