lib/flexirest/request.rb in flexirest-1.10.8 vs lib/flexirest/request.rb in flexirest-1.10.9
- old
+ new
@@ -625,11 +625,11 @@
end
def handle_response(response, cached = nil)
@response = response
status = @response.status || 200
- if @response.body.blank?
+ if @response.body.blank? && !@method[:options][:ignore_empty_response]
@response.response_headers['Content-Type'] = "application/json"
@response.body = "{}"
end
if cached && response.status == 304
@@ -637,9 +637,13 @@
' - Etag copy is the same as the server'
return handle_cached_response(cached)
end
if (200..399).include?(status)
+ if status == 204 || (@response.body.blank? && @method[:options][:ignore_empty_response])
+ return true
+ end
+
if @method[:options][:plain]
return @response = Flexirest::PlainResponse.from_response(@response)
elsif is_json_response? || is_xml_response?
if @response.respond_to?(:proxied) && @response.proxied
Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{@instrumentation_name} - Response was proxied, unable to determine size"