changeset 5790:ac4daf775230 stable

api: avoid sending double Content-Length header (Issue #201) WSGI will take of Content-Length - handling it explicitly was misguided.
author Mads Kiilerich <madski@unity3d.com>
date Sun, 03 Apr 2016 22:45:38 +0200
parents 8c479b274e03
children 73493ddc8c9e
files kallithea/controllers/api/__init__.py
diffstat 1 files changed, 1 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/api/__init__.py	Sun Apr 03 22:45:37 2016 +0200
+++ b/kallithea/controllers/api/__init__.py	Sun Apr 03 22:45:38 2016 +0200
@@ -120,7 +120,6 @@
             log.debug('Content-Length: %s', length)
 
         if length == 0:
-            log.debug("Content-Length is 0")
             return jsonrpc_error(retid=self._req_id,
                                  message="Content-Length is 0")
 
@@ -239,8 +238,7 @@
             exc_info.append(new_exc_info)
 
         output = WSGIController.__call__(self, environ, change_content)
-        output = list(output)
-        headers.append(('Content-Length', str(len(output[0]))))
+        output = list(output) # expand iterator - just to ensure exact timing
         replace_header(headers, 'Content-Type', 'application/json')
         start_response(status[0], headers, exc_info[0])
         log.info('IP: %s Request to %s time: %.3fs' % (