summaryrefslogtreecommitdiff
path: root/swift/common/request_helpers.py
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2018-12-27 23:01:52 +0000
committerTim Burke <tim.burke@gmail.com>2019-02-14 21:23:00 +0000
commit1e3f8a0e5370ea710b13b9aad4ba4f13613b8f41 (patch)
tree5bccad8c5f5f98871516280398603293b62f0a77 /swift/common/request_helpers.py
parent0d29b01d2b8cc5c3a1a1cadf4551839b50eb5d2b (diff)
downloadswift-1e3f8a0e5370ea710b13b9aad4ba4f13613b8f41.tar.gz
Address some review comments
Change-Id: Iacff8a7d7e37557b9a7694ac2df0cfc6b3492024 Related-Change: Ia5815602d05925c5de110accc4dfb1368203bd8d
Diffstat (limited to 'swift/common/request_helpers.py')
-rw-r--r--swift/common/request_helpers.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/swift/common/request_helpers.py b/swift/common/request_helpers.py
index a09ee26c1..78fe771f4 100644
--- a/swift/common/request_helpers.py
+++ b/swift/common/request_helpers.py
@@ -55,7 +55,7 @@ def get_param(req, name, default=None):
:param req: request object
:param name: parameter name
:param default: result to return if the parameter is not found
- :returns: HTTP request parameter value
+ :returns: HTTP request parameter value, as a native string
(in py2, as UTF-8 encoded str, not unicode object)
:raises HTTPBadRequest: if param not valid UTF-8 byte sequence
"""
@@ -70,15 +70,8 @@ def get_param(req, name, default=None):
body='"%s" parameter not valid UTF-8' % name)
else:
if value:
- try:
- if isinstance(value, six.text_type):
- value = value.encode('latin1')
- except UnicodeEncodeError:
- # This happens, remarkably enough, when WSGI string is not
- # a valid latin-1, and passed through parse_qsl().
- raise HTTPBadRequest(
- request=req, content_type='text/plain',
- body='"%s" parameter not valid UTF-8' % name)
+ # req.params is a dict of WSGI strings, so encoding will succeed
+ value = value.encode('latin1')
try:
# Ensure UTF8ness since we're at it
value = value.decode('utf8')