[New-bugs-announce] [issue43912] http.client.BadStatusLine raised and response contains request

Andy Maier report at bugs.python.org
Thu Apr 22 10:02:51 EDT 2021


New submission from Andy Maier <andreas.r.maier at gmx.de>:

Hello, we have a nasty occurrence of BadStatusLine that shows the status line of the request(!!) in one of our projects. That exception is raised when checking a response and should check the response, not the request. 

Further debugging revealed that not only the status line is from the request, but also the headers and the body of the response are from the request when this error happens.

Example exception when using http.client to send the requests:

    http.client.BadStatusLine: POST http://localhost:50000 HTTP/1.1

I have created a standalone script that can be used to reproduce the behavior. The script can use http.client or the requests package for sending the requests. The server is a threaded HTTP server.

The script needs to be run multiple times to reproduce the error. On my local system, the error showed up pretty reliably within the first 50 repetitions of the script.

The header comment of the script explains the details.

If http.client is chosen to be used, the script is purely based on standard Python library functions. The error shows up on all CPython versions I tried, up to 3.9.

----------
components: Library (Lib)
files: badstatusline.py
messages: 391601
nosy: andymaier
priority: normal
severity: normal
status: open
title: http.client.BadStatusLine raised and response contains request
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file49971/badstatusline.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43912>
_______________________________________


More information about the New-bugs-announce mailing list