Skip to content

Document tracing hack with debugfunction #18

Description

@eserte

The curl executable has the useful options --trace and --trace-ascii which are not available in LWP::Protocol::Net::Curl (I suspect that these are not implemented in libcurl, but in the executable). The advantage of these options is that the whole http traffic is shown, unlike when using verbose,1 which shows only request and response headers. However I found out that one can use the debugfunction option to achieve something similar, not nicely formatted, but sufficient for debugging.

If LWP::Protocol::Net::Curl is to be injected into a script which normally just uses LWP and should not be altered to enable the tracing capability, one can use something like

env PERL5OPT=-MLWP::Protocol::Net::Curl=debugfunction,Carp::carp,verbose,1 perl -MLWP::Simple -e 'get(shift)' https://www.example.org 2>&1 | less

or (with newer perl versions only):

env PERL5OPT=-MLWP::Protocol::Net::Curl=debugfunction,CORE::warn,verbose,1 perl -MLWP::Simple -e 'get(shift)' https://www.example.org 2>&1 | less

As I mentioned, the output is not so nice, because the Net::Curl::Easy object is printed first, followed by some integer, and possibly ending with an unrelated code location and line. Additionally it's advisable to pipe the output to a pager, as binary content may be printed, especially if https or compressed data is in use.

I think it would be nice to add this possibility to the documentation. It would be even better if there was a predefined function in LWP::Protocol::Net::Curl which would fix the ugly output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions