summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChmouel Boudjnah <chmouel@chmouel.com>2012-05-08 14:10:14 +0100
committerChmouel Boudjnah <chmouel@chmouel.com>2012-05-08 15:07:58 +0100
commit4c5ee99f5ba8d28ad0c326b91e7aea692ed856d2 (patch)
tree73635aa73a98192c71383a7de7fb5b2d2db6096a
parent9ee3ee6e6d37328bf5fd5e71b08f7b381e33bc22 (diff)
downloadpython-swiftclient-4c5ee99f5ba8d28ad0c326b91e7aea692ed856d2.tar.gz
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.
-rw-r--r--swiftclient/client.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 5b9351e..c31b028 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