Skip to content

Commit bc0e1fb

Browse files
{client,config}: allow passing through additional httpx arguments (#105)
1 parent a5e9a1f commit bc0e1fb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

featureflags/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def authenticate(self):
177177
verify = self._config.tls_trusted_cas_file
178178

179179
client = Client(base_url=self._config.base_url, verify_ssl=verify,
180-
raise_on_unexpected_status=True)
180+
raise_on_unexpected_status=True, httpx_args=self._config.httpx_args)
181181
body = AuthenticationRequest(api_key=self._sdk_key)
182182
response = retryable_authenticate(client=client, body=body).parsed
183183
self._auth_token = response.auth_token
@@ -206,7 +206,8 @@ def make_client(self, url, token, account_id, config):
206206
client = AuthenticatedClient(
207207
base_url=url,
208208
token=token,
209-
verify_ssl=verify
209+
verify_ssl=verify,
210+
httpx_args=self._config.httpx_args,
210211
)
211212
# Additional headers used to track usage
212213
additional_headers = {

featureflags/config.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Configuration is a base class that has default values that you can change
22
during the instance of the client class"""
33

4-
from typing import Callable
4+
from typing import Any, Callable, Dict
55

66
from .interface import Cache
77
from .lru_cache import LRUCache
@@ -28,7 +28,8 @@ def __init__(
2828
enable_stream: bool = True,
2929
enable_analytics: bool = True,
3030
max_auth_retries: int = 10,
31-
tls_trusted_cas_file: str = None
31+
tls_trusted_cas_file: str = None,
32+
httpx_args: Dict[str, Any] = None,
3233
):
3334
self.base_url = base_url
3435
self.events_url = events_url
@@ -49,6 +50,9 @@ def __init__(
4950
self.enable_analytics = enable_analytics
5051
self.max_auth_retries = max_auth_retries
5152
self.tls_trusted_cas_file = tls_trusted_cas_file
53+
self.httpx_args = httpx_args
54+
if self.httpx_args is None:
55+
self.httpx_args = {}
5256

5357

5458
default_config = Config()
@@ -106,3 +110,10 @@ def func(config: Config) -> None:
106110
config.tls_trusted_cas_file = value
107111

108112
return func
113+
114+
115+
def with_httpx_args(args: Dict[str, Any]) -> Callable:
116+
def func(config: Config) -> None:
117+
config.httpx_args.update(args)
118+
119+
return func

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy