NAME

WWW::Curl::TraceAscii - Perl extension interface for libcurl

SYNOPSIS

# 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;

DESCRIPTION

WWW::Curl::TraceAscii adds additional debugging helpers to WWW::Curl::Easy

DOCUMENTATION

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.

WHY DO I NEED A TRACE?

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.

ADDITIONAL METHODS

New methods added above what is normally in WWW::Curl::Easy.

new

Create a new curl object.

setopt

Same as setopt in WWW::Curl::Easy

trace_response

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.

trace_ascii

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.

trace_ascii_init

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);

trace_headers

Returns an array of headers from your curl call.

trace_headers_init

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);