Fix default socket_options value for HTTPSConnection
MODIFY
src/urllib3/connection.py
src/urllib3/connection.py
@@ -356,7 +356,9 @@ class HTTPSConnection(HTTPConnection):
server_hostname: Optional[str] = None,
source_address: Optional[Tuple[str, int]] = None,
blocksize: int = 8192,
- socket_options: Optional[connection.SocketOptions] = None,
+ socket_options: Optional[
+ connection.SocketOptions
+ ] = HTTPConnection.default_socket_options,
proxy: Optional[str] = None,
proxy_config: Optional[ProxyConfig] = None,
) -> None:

MODIFY
test/test_connection.py
test/test_connection.py
import datetime
+import socket
from unittest import mock
import pytest
-from urllib3.connection import RECENT_DATE, CertificateError, _match_hostname
+from urllib3.connection import (
+ RECENT_DATE,
+ CertificateError,
+ HTTPSConnection,
+ _match_hostname,
+)
from urllib3.util.ssl_match_hostname import (
CertificateError as ImplementationCertificateError,
)
@@ -108,3 +114,7 @@ class TestConnection:
# according to the rules defined in that file.
two_years = datetime.timedelta(days=365 * 2)
assert RECENT_DATE > (datetime.datetime.today() - two_years).date()
+
+ def test_HTTPSConnection_default_socket_options(self):
+ conn = HTTPSConnection("not.a.real.host", port=443)
+ assert conn.socket_options == [(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]

Fix default socket_options value for HTTPSConnection