Debugging

HTTPX tries to hide the gory details of protocol handling. However ,it can expose it with its “debug” mode (with verbosity levels), which outputs a lot of details of the internal state, such as connection state, HTTP headers/payload, HTTP/2 frames, all that might be considered relevant for internal debugging or even for bug reporting.

You can enable it either using the options (for localized debugging), or using environment variables (for global library usage debugging).

Options

You can use the :debug option to enable debugging and set the debugging stream ($stderr by default, but can be anything that responds to #<<(String)) and :debug_level to set the verbosity level (1 or 2):

HTTPX.with(debug: STDERR, debug_level: 2).get("https://google.com")
# LOTS OF DEBUGGING OUTPUT

HTTPX_DEBUG

You can use the HTTPX_DEBUG to set the level of debugging from outside your program. This is very useful for script-based debugging (you cannot reset the log stream however, it will default to standard error):

> HTTPX_DEBUG=1 bundle exec ruby my_debugging_script_with_httpx.rb

Next: JRuby/Truffleruby/Other Rubies