Skip to content
Myr

Add `socket_options` argument to `httpx.HTTPTransport` class (#2716)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Add `socket_options` argument to `httpx.HTTPTransport` and `httpx.AsyncHTTPTransport` classes * Update changelog * Fix changelog format * Set httpcore's minimum version to 0.17.2 * Remove SOCKET_OPTIONS import

authored by Karen Petrosyan · committed by GitHub · parent a682f6f · Browse files · 3 files+17 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+17 added−1 removed

  • other:+17 added−1 removed

3 files+17 added−1 removed

modified:httpx/_transports/default.py+12 added
51 unmodified lines
5253T = typing.TypeVar("T", bound="HTTPTransport")54A = typing.TypeVar("A", bound="AsyncHTTPTransport")5556SOCKET_OPTION = typing.Union[57 typing.Tuple[int, int, int],58 typing.Tuple[int, int, typing.Union[bytes, bytearray]],59 typing.Tuple[int, int, None, int],60]616263@contextlib.contextmanager64def map_httpcore_exceptions() -> typing.Iterator[None]:65 try:66 yield
60 unmodified lines
127 proxy: typing.Optional[Proxy] = None,128 uds: typing.Optional[str] = None,129 local_address: typing.Optional[str] = None,130 retries: int = 0,131 socket_options: typing.Optional[typing.Iterable[SOCKET_OPTION]] = None,132 ) -> None:133 ssl_context = create_ssl_context(verify=verify, cert=cert, trust_env=trust_env)134135 if proxy is None:
6 unmodified lines
142 http2=http2,143 uds=uds,144 local_address=local_address,145 retries=retries,146 socket_options=socket_options,147 )148 elif proxy.url.scheme in ("http", "https"):149 self._pool = httpcore.HTTPProxy(150 proxy_url=httpcore.URL(
9 unmodified lines
160 max_keepalive_connections=limits.max_keepalive_connections,161 keepalive_expiry=limits.keepalive_expiry,162 http1=http1,163 http2=http2,164 socket_options=socket_options,165 )166 elif proxy.url.scheme == "socks5":167 try:168 import socksio # noqa
96 unmodified lines
265 proxy: typing.Optional[Proxy] = None,266 uds: typing.Optional[str] = None,267 local_address: typing.Optional[str] = None,268 retries: int = 0,269 socket_options: typing.Optional[typing.Iterable[SOCKET_OPTION]] = None,270 ) -> None:271 ssl_context = create_ssl_context(verify=verify, cert=cert, trust_env=trust_env)272273 if proxy is None:
6 unmodified lines
280 http2=http2,281 uds=uds,282 local_address=local_address,283 retries=retries,284 socket_options=socket_options,285 )286 elif proxy.url.scheme in ("http", "https"):287 self._pool = httpcore.AsyncHTTPProxy(288 proxy_url=httpcore.URL(
9 unmodified lines
298 max_keepalive_connections=limits.max_keepalive_connections,299 keepalive_expiry=limits.keepalive_expiry,300 http1=http1,301 http2=http2,302 socket_options=socket_options,303 )304 elif proxy.url.scheme == "socks5":305 try:306 import socksio # noqa
71 unmodified lines
modified:CHANGELOG.md+4 added
4 unmodified lines
5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).67## Unreleased89### Added1011* Add `socket_options` argument to `httpx.HTTPTransport` and `httpx.AsyncHTTPTransport` classes. (#2716)1213### Fixed1415* Return `500` error response instead of exceptions when `raise_app_exceptions=False` is set on `ASGITransport`. (#2669)16* Ensure all WSGITransport environs have a SERVER_PROTOCOL. (#2708)
1012 unmodified lines
modified:pyproject.toml+1 added-1 removed