diff --git a/swiftclient/client.py b/swiftclient/client.py index 896dd354..98bfb520 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -175,32 +175,6 @@ def http_connection(url, proxy=None): return parsed, conn -def json_request(method, url, **kwargs): - """Takes a request in json parse it and return in json""" - kwargs.setdefault('headers', {}) - if 'body' in kwargs: - kwargs['headers']['Content-Type'] = 'application/json' - kwargs['body'] = json_dumps(kwargs['body']) - parsed, conn = http_connection(url) - conn.request(method, parsed.path, **kwargs) - resp = conn.getresponse() - body = resp.read() - http_log((url, method,), kwargs, resp, body) - if body: - try: - body = json_loads(body) - except ValueError: - body = None - if not body or resp.status < 200 or resp.status >= 300: - 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) - return resp, body - - def get_auth_1_0(url, user, key, snet): parsed, conn = http_connection(url) method = 'GET' diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py index 121456c1..73a28c69 100644 --- a/tests/test_swiftclient.py +++ b/tests/test_swiftclient.py @@ -139,17 +139,6 @@ class TestHttpHelpers(MockHttpTest): url = 'ftp://www.test.com' self.assertRaises(c.ClientException, c.http_connection, url) - def test_json_request(self): - def read(*args, **kwargs): - body = {'a': '1', - 'b': '2'} - return c.json_dumps(body) - c.http_connection = self.fake_http_connection(200, return_read=read) - url = 'http://www.test.com' - _junk, conn = c.json_request('GET', url, body={'username': 'user1', - 'password': 'secure'}) - self.assertTrue(type(conn) is dict) - # TODO: following tests are placeholders, need more tests, better coverage