Repository navigation
Contributor proxy SSL example fails with the documented API #3811
Replies: 2 comments
|
On current |
|
The documented snippet uses two APIs that don't exist in current httpx:
Minimal corrected snippet: import ssl
import httpx
ssl_context = httpx.create_ssl_context()
ssl_context.load_verify_locations("/path/to/client.pem")
with httpx.Client(proxy="http://127.0.0.1:8080/", verify=ssl_context) as client:
response = client.get("https://example.org")
print(response.status_code)
|
Uh oh!
There was an error while loading. Please reload this page.
The development proxy setup in
.github/CONTRIBUTING.mdcurrently callshttpx.SSLContext(), which raisesAttributeError. It also passesssl_context=tohttpx.Client, which raisesTypeError.The version in
docs/contributing.mduses the correctssl.create_default_context(...)/verify=approach, but omits imports and does not close the client.I prepared a small documentation correction that uses a complete context-managed example in both guides and updates the obsolete proxy and SSL links in the GitHub guide. Both corrected code blocks were executed against a local CONNECT proxy and a TLS endpoint using a temporary CA certificate; both returned HTTP 200 with certificate verification enabled.
Would a PR for this documentation correction be welcome?
Prepared with OpenAI Codex assistance.
All reactions