summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChmouel Boudjnah <chmouel@enovance.com>2014-04-15 14:50:10 -0400
committerChmouel Boudjnah <chmouel@enovance.com>2014-04-17 12:04:43 -0400
commit504e5a7f53beb53ee1f099471017d63acf42cf65 (patch)
tree84829161d80ea8a3e13b9fbed8fa1225edc5382f
parent8830c81db7cd86f983e09cf1f4b8705930184bd4 (diff)
downloadpython-swiftclient-504e5a7f53beb53ee1f099471017d63acf42cf65.tar.gz
Remove validate_headers
It wasn't used anymore since moved up to requests (and it fails in py3). Change-Id: Ic8a80ae09ca6445696a9cf34ffb503c5ff51bc79
-rw-r--r--swiftclient/client.py15
-rw-r--r--swiftclient/exceptions.py4
-rw-r--r--tests/test_swiftclient.py20
3 files changed, 1 insertions, 38 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 675fe2e..a482722 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -32,7 +32,7 @@ from time import sleep, time
import six
from swiftclient import version as swiftclient_version
-from swiftclient.exceptions import ClientException, InvalidHeadersException
+from swiftclient.exceptions import ClientException
from swiftclient.utils import LengthWrapper
try:
@@ -109,19 +109,6 @@ def quote(value, safe='/'):
return value
-def validate_headers(headers):
- if headers:
- for key, raw_value in headers.items():
- value = str(encode_utf8(raw_value))
-
- if '\n' in value:
- raise InvalidHeadersException("%r header contained a "
- "newline" % key)
- if '\r' in value:
- raise InvalidHeadersException("%r header contained a "
- "carriage return" % key)
-
-
def encode_utf8(value):
if isinstance(value, six.text_type):
value = value.encode('utf8')
diff --git a/swiftclient/exceptions.py b/swiftclient/exceptions.py
index fe730e5..9a77672 100644
--- a/swiftclient/exceptions.py
+++ b/swiftclient/exceptions.py
@@ -66,7 +66,3 @@ class ClientException(Exception):
b += ' [first 60 chars of response] %s' \
% self.http_response_content[:60]
return b and '%s: %s' % (a, b) or a
-
-
-class InvalidHeadersException(Exception):
- pass
diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py
index bfa3998..6088bf3 100644
--- a/tests/test_swiftclient.py
+++ b/tests/test_swiftclient.py
@@ -248,26 +248,6 @@ class TestHttpHelpers(MockHttpTest):
ua = req_headers.get('user-agent', 'XXX-MISSING-XXX')
self.assertEqual(ua, 'a-new-default')
- def test_validate_headers(self):
- headers = {'key': 'value'}
- self.assertEqual(c.validate_headers(headers), None)
-
- headers = {'key': 'value1\nvalue2'}
- self.assertRaises(c.InvalidHeadersException, c.validate_headers,
- headers)
-
- headers = {'key': 'value1\rvalue2'}
- self.assertRaises(c.InvalidHeadersException, c.validate_headers,
- headers)
-
- def test_validate_headers_with_other_than_str(self):
- values = [None, 1, 1.0, u"A"]
- if six.PY2:
- values.append(long(1))
- for t in values:
- self.assertEqual(c.validate_headers({'key': t}),
- None)
-
# TODO: following tests are placeholders, need more tests, better coverage