You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2012/03/13 14:42:43 UTC
[PATCH core 3/6] Client: Re-use server message for 40x HTTP statuses (DTACLOUD-160)
From: Michal Fojtik <mf...@redhat.com>
Previously the 40x HTTP response status was dropped
and replaced by 'default' description from HTTP specification.
This patch will allow to send user-defined messages from
server. For example code 400 (Bad request) can now indicate
invalid parameters to the client.
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
client/lib/deltacloud.rb | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index e0cb2e4..e6ae89e 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -355,10 +355,10 @@ module DeltaCloud
end
def response_error(response)
- if response.code.to_s =~ /4(\d{2})/
+ xml = Nokogiri::XML(response.to_s)
+ if (xml/'message').empty? and response.code.to_s =~ /4(\d{2})/
DeltaCloud::HTTPError.client_error(response.code)
else
- xml = Nokogiri::XML(response.to_s)
opts = {
:driver => (xml/'backend').first[:driver],
:provider => (xml/'backend').first[:provider],
--
1.7.9.1