This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: http.client.BadStatusLine raised and response contains request
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: andymaier
Priority: normal Keywords:

Created on 2021-04-22 14:02 by andymaier, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
badstatusline.py andymaier, 2021-04-22 14:02 Script to reproduce the error
Messages (2)
msg391601 - (view) Author: Andy Maier (andymaier) * Date: 2021-04-22 14:02
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.
msg391602 - (view) Author: Andy Maier (andymaier) * Date: 2021-04-22 14:14
I should have added that my local system is macOS, and that "up to 3.9" means I only tried up to 3.9.
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 88078
2021-04-22 14:14:25andymaiersetmessages: + msg391602
2021-04-22 14:02:51andymaiercreate