Environment Variables ===================== The HTTPX library can be configured via environment variables. Here is a list of environment variables that HTTPX recognizes and what function they serve: `HTTPX_DEBUG` ----------- Valid values: `1`, `true` If this environment variable is set to a valid value then low-level details about the execution of HTTP requests will be logged to `stderr`. This can help you debug issues and see what's exactly being sent over the wire and to which location. Example: ```python # test_script.py import httpx client = httpx.Client() client.get("https://google.com") ``` ```console user@host:~$ HTTPX_DEBUG=1 python test_script.py 20:54:17.585 - httpx.dispatch.connection_pool - acquire_connection origin=Origin(scheme='https' host='www.google.com' port=443) 20:54:17.585 - httpx.dispatch.connection_pool - new_connection connection=HTTPConnection(origin=Origin(scheme='https' host='www.google.com' port=443)) 20:54:17.590 - httpx.dispatch.connection - start_connect host='www.google.com' port=443 timeout=TimeoutConfig(timeout=5.0) 20:54:17.651 - httpx.dispatch.connection - connected http_version='HTTP/2' 20:54:17.651 - httpx.dispatch.http2 - send_headers stream_id=1 headers=[(b':method', b'GET'), (b':authority', b'www.google.com'), ...] 20:54:17.652 - httpx.dispatch.http2 - end_stream stream_id=1 20:54:17.681 - httpx.dispatch.http2 - receive_event stream_id=0 event= 20:54:17.681 - httpx.dispatch.http2 - receive_event stream_id=0 event= 20:54:17.682 - httpx.dispatch.http2 - receive_event stream_id=0 event= 20:54:17.739 - httpx.dispatch.http2 - receive_event stream_id=1 event= 20:54:17.741 - httpx.dispatch.http2 - receive_event stream_id=1 event= 20:54:17.742 - httpx.dispatch.http2 - receive_event stream_id=1 event= 20:54:17.742 - httpx.dispatch.http2 - receive_event stream_id=1 event= 20:54:17.742 - httpx.dispatch.http2 - receive_event stream_id=0 event= 20:54:17.743 - httpx.dispatch.connection_pool - release_connection connection=HTTPConnection(origin=Origin(scheme='https' host='www.google.com' port=443)) ``` `SSLKEYLOGFILE` ----------- Valid values: a filename If this environment variable is set, TLS keys will be appended to the specified file, creating it if it doesn't exist, whenever key material is generated or received. The keylog file is designed for debugging purposes only. Support for `SSLKEYLOGFILE` requires Python 3.8 and OpenSSL 1.1.1 or newer. Example: ```python # test_script.py import httpx client = httpx.Client() client.get("https://google.com") ``` ```console SSLKEYLOGFILE=test.log python test_script.py cat test.log # TLS secrets log file, generated by OpenSSL / Python SERVER_HANDSHAKE_TRAFFIC_SECRET XXXX EXPORTER_SECRET XXXX SERVER_TRAFFIC_SECRET_0 XXXX CLIENT_HANDSHAKE_TRAFFIC_SECRET XXXX CLIENT_TRAFFIC_SECRET_0 XXXX SERVER_HANDSHAKE_TRAFFIC_SECRET XXXX EXPORTER_SECRET XXXX SERVER_TRAFFIC_SECRET_0 XXXX CLIENT_HANDSHAKE_TRAFFIC_SECRET XXXX CLIENT_TRAFFIC_SECRET_0 XXXX ```