From 381d9ba941e93386000dd29b9426358efb7713f7 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Sat, 12 Apr 2014 08:00:33 -0700 Subject: [PATCH] Fix a response header bug in the error middleware Coerce the Content-Length of the custom error message to a string, not an integer. Some pure Python WSGI servers aren't strict and violate the WSGI specification by automatically converting the value to a string. Apache, however, *is* strict, and considers this a 500 Internal Error Fixes bug 1306963 Change-Id: I9b82ceee096b00c21c3b230dc67701bc40629968 --- ceilometer/api/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ceilometer/api/middleware.py b/ceilometer/api/middleware.py index 3e9bfc676..2e04c5160 100644 --- a/ceilometer/api/middleware.py +++ b/ceilometer/api/middleware.py @@ -124,7 +124,7 @@ class ParsableErrorMiddleware(object): except ValueError as err: body = [json.dumps({'error_message': '\n'.join(app_iter)})] state['headers'].append(('Content-Type', 'application/json')) - state['headers'].append(('Content-Length', len(body[0]))) + state['headers'].append(('Content-Length', str(len(body[0])))) else: body = app_iter return body