HTTPX
tries to hide the gory details of protocol handling. However, it can expose them with its “debug” mode (with verbosity levels), which outputs connection state, HTTP headers/payload, HTTP/2 frames, all that might be considered relevant for internal debugging purposes, or even just for bug reporting.
You can enable it either by using session or request options (for single-request debugging), or using environment variables (for whole process debugging).
You can use the :debug
option to enable debugging and set the debugging stream (anything that responds to #<<(String)
, like STDERR
) and :debug_level
to set the verbosity level (1
or 2
, the latter being more verbose):
HTTPX.with(debug: STDERR, debug_level: 2).get("https://google.com")
# LOTS OF DEBUGGING OUTPUT
You can use the HTTPX_DEBUG
to set the level of debugging from outside your program. This is very useful for script-based debugging:
> HTTPX_DEBUG=1 bundle exec ruby my_debugging_script_with_httpx.rb
When HTTPX_DEBUG
is used, the logs will be written to standard error.