summaryrefslogtreecommitdiff
path: root/t/new/03body-callback.t
blob: c91d5855f98989517243226ca0a38f8c5bd7510b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use strict;
use Test::More tests => 1;
use WWW::Curl::Easy;

my $body;

sub body_callback {
    my ( $chunk, $handle ) = @_;
    $body .= $chunk;
    return length $chunk;
}

SKIP: {
    skip 'You need to set CURL_TEST_URL', 1 unless $ENV{CURL_TEST_URL};
    my $curl = new WWW::Curl::Easy;
    $curl->setopt( CURLOPT_URL,           $ENV{CURL_TEST_URL} );
    $curl->setopt( CURLOPT_WRITEFUNCTION, \&body_callback );
    $curl->perform;
    ok($body);
}