Repository navigation
Consider warning caller if supplied client params will in favour of transport
#3134
Replies: 1 comment
|
The split is between client behavior and transport construction. import ssl
import httpx
def make_client():
context = ssl.create_default_context()
# For mutual TLS, load your real files here:
# context.load_cert_chain("client-cert.pem", "client-key.pem")
transport = httpx.AsyncHTTPTransport(
retries=3, verify=context, trust_env=False,
)
return httpx.AsyncClient(
transport=transport, trust_env=False,
base_url="https://example.com",
)Use A warning would need to distinguish explicit options from defaults and account for arbitrary third-party transports; the example above does not resolve that API-design question. Validated construction, base-URL handling, and closing on 0.28.1; no real mTLS handshake was tested. SSL configuration, custom transports. Validation version: HTTPX 0.28.1, Python 3.11.9. |
Uh oh!
There was an error while loading. Please reload this page.
First of all, thanks for a great library!
I recently got surprised when debugging something to find that if you do:
You won't get cert config
trust_envrespected (but yourbase_urlwill be)I agree that the precedence logic (
transportoverriding params) probably makes sense, but it feels risky to take these parameters, some of which set up important security features, and silently ignore them if another parameter is supplied.It seems some others have been surprised here (See #2888, #2513 (comment))
Note also this might probably come into focus more now, with the deprecation of
app=appmethod of setting up a client (this is how we got to creating a transport manually).Perhaps a warning of some sort might help here?
All reactions