From 4c5ee99f5ba8d28ad0c326b91e7aea692ed856d2 Mon Sep 17 00:00:00 2001
From: Chmouel Boudjnah <chmouel@chmouel.com>
Date: Tue, 8 May 2012 14:10:14 +0100
Subject: [PATCH] Make sure we get a header StorageURL with 1.0

- Since RAX auth always come back with 200 we can't check with status code.
---
 swiftclient/client.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/swiftclient/client.py b/swiftclient/client.py
index 5b9351e8..c31b028e 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -169,13 +169,17 @@ def _get_auth_v1_0(url, user, key, snet):
     conn.request('GET', parsed.path, '',
                  {'X-Auth-User': user, 'X-Auth-Key': key})
     resp = conn.getresponse()
-    resp.read()
-    if resp.status < 200 or resp.status >= 300:
+    body = resp.read()
+    url = resp.getheader('x-storage-url')
+
+    # There is a side-effect on current Rackspace 1.0 server where a
+    # bad URL would get you that document page and a 200. We error out
+    # if we don't have a x-storage-url header and if we get a body.
+    if resp.status < 200 or resp.status >= 300 or (body and not url):
         raise ClientException('Auth GET failed', http_scheme=parsed.scheme,
                 http_host=conn.host, http_port=conn.port,
                 http_path=parsed.path, http_status=resp.status,
                 http_reason=resp.reason)
-    url = resp.getheader('x-storage-url')
     if snet:
         parsed = list(urlparse(url))
         # Second item in the list is the netloc