From 55b3b5f9d7d07aca27624f8811064bfb333a5e09 Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Thu, 17 Oct 2013 11:51:03 +0400 Subject: [PATCH] Add HTTPNotModified exception. Use raw_request for getting .tar.gz files. --- metadataclient/common/exceptions.py | 4 ++++ metadataclient/common/http.py | 8 +------- metadataclient/v1/metadata_client.py | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/metadataclient/common/exceptions.py b/metadataclient/common/exceptions.py index a8e2fef..31fa931 100644 --- a/metadataclient/common/exceptions.py +++ b/metadataclient/common/exceptions.py @@ -62,6 +62,10 @@ class HTTPMultipleChoices(HTTPException): self.details) +class HTTPNotModified(HTTPException): + code = 304 + + class BadRequest(HTTPException): """DEPRECATED!""" code = 400 diff --git a/metadataclient/common/http.py b/metadataclient/common/http.py index b08c36c..242a8f7 100644 --- a/metadataclient/common/http.py +++ b/metadataclient/common/http.py @@ -235,7 +235,7 @@ class HTTPClient(object): elif resp.status in (301, 302, 305): # Redirected. Reissue the request to the new location. return self._http_request(resp['location'], method, **kwargs) - elif resp.status == 300: + elif resp.status in (300, 304): raise exc.from_response(resp) return resp, body_iter @@ -272,12 +272,6 @@ class HTTPClient(object): kwargs['headers']['Transfer-Encoding'] = 'chunked' return self._http_request(url, method, **kwargs) - def archive_request(self, method, url, **kwargs): - kwargs.setdefault('headers', {}) - kwargs['headers'].setdefault('Content-Type', - 'application/x-tar') - return self._http_request(url, method, **kwargs) - class OpenSSLConnectionDelegator(object): """ diff --git a/metadataclient/v1/metadata_client.py b/metadataclient/v1/metadata_client.py index cd509ac..ab29971 100644 --- a/metadataclient/v1/metadata_client.py +++ b/metadataclient/v1/metadata_client.py @@ -39,7 +39,7 @@ class Controller(object): """ url = '/v1/client/ui' - resp, body = self.http_client.archive_request('GET', url) + resp, body = self.http_client.raw_request('GET', url) return body def get_conductor_data(self): @@ -48,5 +48,5 @@ class Controller(object): """ url = '/v1/client/conductor' - resp, body = self.http_client.archive_request('GET', url) + resp, body = self.http_client.raw_request('GET', url) return body \ No newline at end of file