Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
While trying to useread1 in urllib3, we discovered thatread1 unlikeread never closes the response after reading all data when the content length is known (urllib3/urllib3#3235).
importhttp.clientconn=http.client.HTTPSConnection("www.python.org")conn.request("GET","/")response=conn.getresponse()
This runs successfully:
response.read()assertresponse.isclosed()
This fails:
whileresponse.read1():passassertresponse.isclosed()
CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
Linux, macOS, Windows
Linked PRs
- gh-113199: Make
read1andreadlineofHTTPResponseclose IO after reading all data #113200 - [3.12] gh-113199: Make read1() and readline() of HTTPResponse close IO after reading all data (GH-113200) #113259
- [3.11] gh-113199: Make read1() and readline() of HTTPResponse close IO after reading all data (GH-113200) #113260