Subject
HTTPResponse.stream generator can safely handle the situation when amt is positive integer, negative integer and None. However, amt=0 can lead to catastrophic infinite loop (while HTTPResponse.read(0) is legit). This behavior is implicit, not covered in docs and tests.
Steps to Reproduce
import urllib3
r = urllib3.request("GET", "https://example.com", preload_content=False)
for chunk in r.stream(0):
print(chunk)
Actual Behavior
Run into infinite loop
Expected Behavior
Anything else (handled the same way as None / explicitly raise a ValueError / return with empty output, etc.)
Subject
HTTPResponse.streamgenerator can safely handle the situation when amt is positive integer, negative integer andNone. However,amt=0can lead to catastrophic infinite loop (whileHTTPResponse.read(0)is legit). This behavior is implicit, not covered in docs and tests.Steps to Reproduce
Actual Behavior
Run into infinite loop
Expected Behavior
Anything else (handled the same way as
None/ explicitly raise a ValueError / return with empty output, etc.)