diff --git a/swift/common/middleware/gatekeeper.py b/swift/common/middleware/gatekeeper.py index 991ec86cd9..17a985defd 100644 --- a/swift/common/middleware/gatekeeper.py +++ b/swift/common/middleware/gatekeeper.py @@ -92,7 +92,7 @@ class GatekeeperMiddleware(object): def gatekeeper_response(status, response_headers, exc_info=None): def fixed_response_headers(): def relative_path(value): - parsed = urlsplit(v) + parsed = urlsplit(value) new_path = parsed.path if parsed.query: new_path += ('?%s' % parsed.query) diff --git a/swift/common/swob.py b/swift/common/swob.py index 5c38c5d8fd..b7163065d2 100644 --- a/swift/common/swob.py +++ b/swift/common/swob.py @@ -288,10 +288,8 @@ def _resp_status_property(): self.status_int = value self.explanation = self.title = RESPONSE_REASONS[value][0] else: - if isinstance(value, six.text_type): - value = value.encode('utf-8') - self.status_int = int(value.split(b' ', 1)[0]) - self.explanation = self.title = value.split(b' ', 1)[1] + self.status_int = int(value.split(' ', 1)[0]) + self.explanation = self.title = value.split(' ', 1)[1] return property(getter, setter, doc="Retrieve and set the Response status, e.g. '200 OK'") @@ -309,7 +307,7 @@ def _resp_body_property(): if not self._app_iter: return '' with closing_if_possible(self._app_iter): - self._body = ''.join(self._app_iter) + self._body = b''.join(self._app_iter) self._app_iter = None return self._body @@ -1400,7 +1398,7 @@ class Response(object): if 'location' in self.headers and \ not env.get('swift.leave_relative_location'): self.location = self.absolute_location() - start_response(self.status, self.headers.items()) + start_response(self.status, list(self.headers.items())) return self.response_iter diff --git a/test/unit/common/middleware/test_gatekeeper.py b/test/unit/common/middleware/test_gatekeeper.py index d8c09368c3..37cbe04888 100644 --- a/test/unit/common/middleware/test_gatekeeper.py +++ b/test/unit/common/middleware/test_gatekeeper.py @@ -104,7 +104,7 @@ class TestGatekeeper(unittest.TestCase): app = self.get_app(fake_app, {}) resp = req.get_response(app) self.assertEqual('200 OK', resp.status) - self.assertEqual(resp.body, 'FAKE APP') + self.assertEqual(resp.body, b'FAKE APP') self._assertHeadersEqual(self.allowed_headers, fake_app.req.headers) def _test_reserved_header_removed_inbound(self, method): diff --git a/tox.ini b/tox.ini index 64dbaed7d8..d07d99ee3d 100644 --- a/tox.ini +++ b/tox.ini @@ -36,6 +36,7 @@ commands = test/unit/cli/test_relinker.py \ test/unit/cli/test_ring_builder_analyzer.py \ test/unit/cli/test_ringbuilder.py \ + test/unit/common/middleware/test_gatekeeper.py \ test/unit/common/ring \ test/unit/common/test_daemon.py \ test/unit/common/test_exceptions.py \