Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document tracing hack with debugfunction #18

Open
eserte opened this issue Jun 1, 2023 · 0 comments
Open

Document tracing hack with debugfunction #18

eserte opened this issue Jun 1, 2023 · 0 comments

Comments

@eserte
Copy link

eserte commented Jun 1, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant