1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
use strict;
use Test::More tests => 1;
use WWW::Curl::Easy;
my $max = 1000;
sub read_callback {
my ( $maxlen, $sv ) = @_;
# Create some random data
my $data = chr( ord('A') + rand(26) ) x ( int( $max / 3 ) + 1 );
$max = $max - length $data;
return $data;
}
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_READFUNCTION, \&read_callback );
$curl->setopt( CURLOPT_INFILESIZE, $max );
$curl->setopt( CURLOPT_UPLOAD, 1 );
$curl->setopt( CURLOPT_CUSTOMREQUEST, 'POST' );
my $code = $curl->perform;
ok( $code == 0 );
}
|