﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33115	Connection issue after a HEAD is used	Dave Johansen	nobody	"We noticed that monitoring checks using HEAD were causing `ConnectionResetError` issues in our logs. We believe that this may be causing issues with some other requests, but haven't been able to verify that yet. However, there's a simple way to reproduce this issue. Simply [[https://docs.djangoproject.com/en/3.2/intro/tutorial01/|create a new project and run it using the instructions from the tutorial]] and then run a command like this `curl -I http://localhost:8000/ http://localhost:8000/` or run a Python script like this:
{{{
import logging

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
}}}"	Bug	closed	HTTP handling	2.2	Normal	duplicate	keepalive		Unreviewed	0	0	0	0	0	0
