Ticket #4650: stale_connections_fix.diff

File stale_connections_fix.diff, 1.6 KB (added by Ilya Semenov <semenov@…>, 8 years ago)
  • core/handlers/modpython.py

     
    153153            for middleware_method in self._response_middleware:
    154154                response = middleware_method(request, response)
    155155
     156            # Convert our custom HttpResponse object back into the mod_python req.
     157            req.content_type = response['Content-Type']
     158            for key, value in response.headers.items():
     159                if key != 'Content-Type':
     160                    req.headers_out[key] = value
     161            for c in response.cookies.values():
     162                req.headers_out.add('Set-Cookie', c.output(header=''))
     163            req.status = response.status_code
     164            try:
     165                for chunk in response:
     166                    req.write(chunk)
     167            finally:
     168                response.close()
     169
    156170        finally:
    157171            dispatcher.send(signal=signals.request_finished)
    158172
    159         # Convert our custom HttpResponse object back into the mod_python req.
    160         req.content_type = response['Content-Type']
    161         for key, value in response.headers.items():
    162             if key != 'Content-Type':
    163                 req.headers_out[key] = value
    164         for c in response.cookies.values():
    165             req.headers_out.add('Set-Cookie', c.output(header=''))
    166         req.status = response.status_code
    167         try:
    168             for chunk in response:
    169                 req.write(chunk)
    170         finally:
    171             response.close()
    172 
    173173        return 0 # mod_python.apache.OK
    174174
    175175def handler(req):
Back to Top