WWW::Curl::TraceAscii - Perl extension interface for libcurl
# Just like WWW::Curl::Easy, no fancy overrides use WWW::Curl::TraceAscii; # Overrides WWW::Curl::Easy->new use WWW::Curl::TraceAscii qw(:new); # GET Example use WWW::Curl::TraceAscii; my $curl = WWW::Curl::TraceAscii->new; $curl->setopt(CURLOPT_URL, 'http://example.com'); $curl->perform; my $response_PTR = $curl->trace_response; # POST Example use WWW::Curl::TraceAscii; my $response; my $post = "some post data"; my $curl = WWW::Curl::TraceAscii->new; $curl->setopt(CURLOPT_POST, 1); $curl->setopt(CURLOPT_POSTFIELDS, $post); $curl->setopt(CURLOPT_URL,'http://example.com/'); $curl->setopt(CURLOPT_WRITEDATA,\$response); $curl->perform; # These methods only exist in TraceAscii my $response_PTR = $curl->trace_response; my $headers_PTR = $curl->trace_headers; my $trace_ascii_PTR = $curl->trace_ascii;
WWW::Curl::TraceAscii adds additional debugging helpers to WWW::Curl::Easy
This module uses WWW::Curl::Easy at it's base. WWW::Curl::TraceAscii gives you the ability to record a log of your curl connection much like the --trace-ascii feature inside the curl binary.
I've been curling pages for decades. Usually in an automatic fashion. And while you can write code that will handle almost all failures. You can't answer the question that will inevitably be asked for a result you didn't expect... What happened??
I've seen hundreds of different types of errors come through that without a good trace would have been impossible to get a difinitive answer as to what happened.
I've personally gotten into the practice of storing the trace data for all connections. This allows me to review exactly what happened, even if the problem was only temporary. Especially if the problem was fixed before I was able to review it.
New methods added above what is normally in WWW::Curl::Easy.
Create a new curl object.
Same as setopt in WWW::Curl::Easy
This can get rather lengthy. So to save memory it returns a pointer to the response data.
NOTE: You can still set CURLOPT_WRITEDATA yourself if you pefer.
Mimic the curl binary when you enable the --trace-ascii and --trace-time command line options. Minus the SSL negotiation data.
This can get rather lengthy. So to save memory it returns a pointer to the trace data.
The actual method used to produce the trace_ascii output.
In WWW::Curl::Easy you would initialize this like so: my $trace_ascii = &trace_ascii_init($curl);
Returns an array of headers from your curl call.
The actual method used to produce the trace_headers output.
In WWW::Curl::Easy you would initialize this like so: $headers = &trace_headers_init($curl);
To install WWW::Curl::TraceAscii, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Curl::TraceAscii
CPAN shell
perl -MCPAN -e shell install WWW::Curl::TraceAscii
For more information on module installation, please visit the detailed CPAN module installation guide.