From 2c100e84a36c8ac5fac0684b201ce2050ba1aab0 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 31 Mar 2009 06:15:13 +0000 Subject: - Fix a bug in ``repoze.bfg.wsgi.HTTPException``: the content length was returned as an int rather than as a string. --- repoze/bfg/tests/test_wsgi.py | 8 ++++---- repoze/bfg/wsgi.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'repoze') diff --git a/repoze/bfg/tests/test_wsgi.py b/repoze/bfg/tests/test_wsgi.py index 95eaecf80..1fd2393b8 100644 --- a/repoze/bfg/tests/test_wsgi.py +++ b/repoze/bfg/tests/test_wsgi.py @@ -30,7 +30,7 @@ class TestNotFound(unittest.TestCase): self.assertEqual(len(result), 1) self.failUnless('404 Not Found' in result[0]) self.assertEqual(L[0][0], '404 Not Found') - self.assertEqual(L[0][1], [('Content-Length', len(result[0])), + self.assertEqual(L[0][1], [('Content-Length', str(len(result[0]))), ('Content-Type', 'text/html')]) def test_with_message(self): @@ -44,7 +44,7 @@ class TestNotFound(unittest.TestCase): self.failUnless('404 Not Found' in result[0]) self.failUnless('<hi!>' in result[0]) self.assertEqual(L[0][0], '404 Not Found') - self.assertEqual(L[0][1], [('Content-Length', len(result[0])), + self.assertEqual(L[0][1], [('Content-Length', str(len(result[0]))), ('Content-Type', 'text/html')]) class TestUnauthorized(unittest.TestCase): @@ -65,7 +65,7 @@ class TestUnauthorized(unittest.TestCase): self.assertEqual(len(result), 1) self.failUnless('401 Unauthorized' in result[0]) self.assertEqual(L[0][0], '401 Unauthorized') - self.assertEqual(L[0][1], [('Content-Length', len(result[0])), + self.assertEqual(L[0][1], [('Content-Length', str(len(result[0]))), ('Content-Type', 'text/html')]) def test_with_message(self): @@ -79,7 +79,7 @@ class TestUnauthorized(unittest.TestCase): self.failUnless('401 Unauthorized' in result[0]) self.failUnless('<hi!>' in result[0]) self.assertEqual(L[0][0], '401 Unauthorized') - self.assertEqual(L[0][1], [('Content-Length', len(result[0])), + self.assertEqual(L[0][1], [('Content-Length', str(len(result[0]))), ('Content-Type', 'text/html')]) def dummyapp(environ, start_response): diff --git a/repoze/bfg/wsgi.py b/repoze/bfg/wsgi.py index 1a2c0460b..667de4412 100644 --- a/repoze/bfg/wsgi.py +++ b/repoze/bfg/wsgi.py @@ -44,7 +44,8 @@ class HTTPException(object): %s

%s

%s """ % (self.status, self.status, msg) - headers = [('Content-Length', len(html)), ('Content-Type', 'text/html')] + headers = [('Content-Length', str(len(html))), + ('Content-Type', 'text/html')] start_response(self.status, headers) return [html] -- cgit v1.2.3