Enable enforce_content_length=True by default
Data longer than Content-Length header will no longer be silently dropped when streaming
ADD
changelog/2514.bugfix.rst
+Change `enforce_content_length` default to True, preventing silent data loss when reading streamed responses.

MODIFY
src/urllib3/response.py
src/urllib3/response.py
@@ -419,7 +419,7 @@ class HTTPResponse(BaseHTTPResponse):
connection: Optional[HTTPConnection] = None,
msg: Optional[_HttplibHTTPMessage] = None,
retries: Optional[Retry] = None,
- enforce_content_length: bool = False,
+ enforce_content_length: bool = True,
request_method: Optional[str] = None,
request_url: Optional[str] = None,
auto_close: bool = True,

Enable enforce_content_length=True by default

Data longer than Content-Length header will no longer be silently dropped when streaming