#28440: Runserver does not correctly close connections once a response is sent
-------------------------------+--------------------------------------
     Reporter:  Tom            |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  HTTP handling  |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by Tim Graham):

 I don't see the behavior you describe on Linux. Not sure if I interpreted
 your suggested patch correctly but:
 {{{ #!diff
 diff --git a/django/core/servers/basehttp.py
 b/django/core/servers/basehttp.py
 index d725241..d0309b7 100644
 --- a/django/core/servers/basehttp.py
 +++ b/django/core/servers/basehttp.py
 @@ -134,13 +134,6 @@ class
 WSGIRequestHandler(simple_server.WSGIRequestHandler):

          return super().get_environ()

 -    def handle(self):
 -        """Handle multiple requests if necessary."""
 -        self.close_connection = 1
 -        self.handle_one_request()
 -        while not self.close_connection:
 -            self.handle_one_request()
 -
      def handle_one_request(self):
          """Copy of WSGIRequestHandler.handle() but with different
 ServerHandler"""
          self.raw_requestline = self.rfile.readline(65537)
 @@ -160,6 +153,7 @@ class
 WSGIRequestHandler(simple_server.WSGIRequestHandler):
          handler.request_handler = self      # backpointer for logging
          handler.run(self.server.get_app())

 +    handle = handle_one_request

  def run(addr, port, wsgi_handler, ipv6=False, threading=False,
 server_cls=WSGIServer):
      server_address = (addr, port)
 }}}
 gives this test failure:
 {{{
 ======================================================================
 ERROR: test_protocol (servers.tests.LiveServerViews)
 Launched server serves with HTTP 1.1.
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/opt/python3.6.2/lib/python3.6/unittest/case.py", line 59, in
 testPartExecutor
     yield
   File "/opt/python3.6.2/lib/python3.6/unittest/case.py", line 605, in run
     testMethod()
   File "/home/tim/code/django/tests/servers/tests.py", line 64, in
 test_protocol
     conn.getresponse()
   File "/opt/python3.6.2/lib/python3.6/http/client.py", line 1331, in
 getresponse
     response.begin()
   File "/opt/python3.6.2/lib/python3.6/http/client.py", line 297, in begin
     version, status, reason = self._read_status()
   File "/opt/python3.6.2/lib/python3.6/http/client.py", line 266, in
 _read_status
     raise RemoteDisconnected("Remote end closed connection without"
 http.client.RemoteDisconnected: Remote end closed connection without
 response
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28440#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/061.fd7b7a0f21a9e2a8478f4a09330f1b47%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to