deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 3/6] Client: Re-use server message for 40x HTTP statuses (DTACLOUD-160)
Date Tue, 13 Mar 2012 13:42:43 GMT
From: Michal Fojtik <mfojtik@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 <mfojtik@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


Mime
View raw message