[New-bugs-announce] [issue42432] Http client, Bad Status Line triggered for no reason

sicarius noidea report at bugs.python.org
Sun Nov 22 04:59:54 EST 2020


New submission from sicarius noidea <sicarius.ctf at gmail.com>:

Hey,
BadStatusLine triggered when protocol version is in lowercase. 
I've encountered a server that answers "Http/1.0  404 Not Found\r\n" instead of "HTTP/1.0  404 Not Found\r\n"

## Expected Result

Requests understanding the status line.

## Actual Result

Requests is closing the connection.

## Reproduction Steps
### Setup a server that answers the line above
bash: ```while 1;do echo "Http/1.0  404 Not Found\r\n" | sudo nc -lnvp 80; done```
### get the server
```python
import requests
req = req = requests.get("http://127.0.0.1/", verify=False, allow_redir=False )
```

## problem location
Look at line 287 of http/client.py
the word "HTTP" should be matched in lowercase too.
```python
if not version.startswith("HTTP/"):```

Regards.

----------
components: Library (Lib)
messages: 381606
nosy: sicarius.ctf
priority: normal
severity: normal
status: open
title: Http client, Bad Status Line triggered for no reason
type: behavior
versions: Python 3.9

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


More information about the New-bugs-announce mailing list