import requests
logging.basicConfig(level=logging.DEBUG)
s = requests.Session()
r = s.head('http://localhost:8000/')
print(r.status_code, r.text)
r = s.head('http://localhost:8000/')
print(r.status_code, r.text)
}}}
And you'll notice an output like this:
{{{
16/Sep/2021 16:02:17] "HEAD / HTTP/1.1" 200 16348
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 44808)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/socketserver.py", line 650, in
process_request_thread
self.finish_request(request, client_address)
File "/usr/local/lib/python3.7/socketserver.py", line 360, in
finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python3.7/socketserver.py", line 720, in __init__
self.handle()
File "/usr/local/lib/python3.7/site-
packages/django/core/servers/basehttp.py", line 171, in handle
self.handle_one_request()
File "/usr/local/lib/python3.7/site-
packages/django/core/servers/basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------
[16/Sep/2021 16:02:18] "HEAD / HTTP/1.1" 200 16348
}}}
Or with 3.2, an output like this:
{{{
[16/Sep/2021 23:31:37] "HEAD / HTTP/1.1" 200 10697
[16/Sep/2021 23:31:37,819] - Broken pipe from ('127.0.0.1', 46600)
[16/Sep/2021 23:31:45] "HEAD / HTTP/1.1" 200 10697
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33115>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
* component: Core (Other) => HTTP handling
Comment:
It's a duplicate of #28054 and #29343, the proposed
[https://github.com/django/django/pull/10676 PR] fixes this issue for me.
--
Ticket URL: <https://code.djangoproject.com/ticket/33115#comment:1>