diff --git a/swift/common/middleware/crossdomain.py b/swift/common/middleware/crossdomain.py index d2cd5d2df3..13a45a316b 100644 --- a/swift/common/middleware/crossdomain.py +++ b/swift/common/middleware/crossdomain.py @@ -71,7 +71,7 @@ class CrossDomainMiddleware(object): '\n' \ '%s\n' \ '' % self.cross_domain_policy - return Response(request=req, body=body, + return Response(request=req, body=body.encode('utf-8'), content_type="application/xml") def __call__(self, env, start_response): diff --git a/test/unit/common/middleware/test_crossdomain.py b/test/unit/common/middleware/test_crossdomain.py index aa08c94cca..d5d1f09be1 100644 --- a/test/unit/common/middleware/test_crossdomain.py +++ b/test/unit/common/middleware/test_crossdomain.py @@ -23,7 +23,7 @@ from swift.common.middleware import crossdomain class FakeApp(object): def __call__(self, env, start_response): - return "FAKE APP" + return b"FAKE APP" def start_response(*args): @@ -37,12 +37,12 @@ class TestCrossDomain(unittest.TestCase): # GET of /crossdomain.xml (default) def test_crossdomain_default(self): - expectedResponse = '\n' \ - '\n' \ - '\n' \ - '\n' \ - '' + expectedResponse = b'\n' \ + b'\n' \ + b'\n' \ + b'\n' \ + b'' req = Request.blank('/crossdomain.xml', environ={'REQUEST_METHOD': 'GET'}) @@ -53,13 +53,13 @@ class TestCrossDomain(unittest.TestCase): def test_crossdomain_custom(self): conf = {'cross_domain_policy': '\n'} self.app = crossdomain.CrossDomainMiddleware(FakeApp(), conf) - expectedResponse = '\n' \ - '\n' \ - '\n' \ - '\n' \ - '\n' \ - '' + expectedResponse = b'\n' \ + b'\n' \ + b'\n' \ + b'\n' \ + b'\n' \ + b'' req = Request.blank('/crossdomain.xml', environ={'REQUEST_METHOD': 'GET'}) @@ -70,7 +70,7 @@ class TestCrossDomain(unittest.TestCase): def test_crossdomain_pass(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) resp = self.app(req.environ, start_response) - self.assertEqual(resp, 'FAKE APP') + self.assertEqual(resp, b'FAKE APP') # Only GET is allowed on the /crossdomain.xml resource def test_crossdomain_get_only(self): @@ -78,7 +78,7 @@ class TestCrossDomain(unittest.TestCase): req = Request.blank('/crossdomain.xml', environ={'REQUEST_METHOD': method}) resp = self.app(req.environ, start_response) - self.assertEqual(resp, 'FAKE APP') + self.assertEqual(resp, b'FAKE APP') if __name__ == '__main__': diff --git a/tox.ini b/tox.ini index c8baa7283c..1bec86a68b 100644 --- a/tox.ini +++ b/tox.ini @@ -37,6 +37,7 @@ commands = test/unit/cli/test_ring_builder_analyzer.py \ test/unit/cli/test_ringbuilder.py \ test/unit/common/middleware/test_catch_errors.py \ + test/unit/common/middleware/test_crossdomain.py \ test/unit/common/middleware/test_gatekeeper.py \ test/unit/common/middleware/test_healthcheck.py \ test/unit/common/middleware/test_proxy_logging.py \