curl-library
Perl-curl-lib : PUT method & CURL_WRITEFUNCTION
Date: Fri, 22 Jun 2001 17:14:32 +0200 (CEST)
Hello,
I'm doing some testing but when i tried that, i got an error like
"Failed writing body
Receeived problem in the chunky parser ". I suspect i'm not using
correctly the api but what ? Without CURL_WRITEFUNCTION all is working
correctly and the file is created on the HTTP server via the PUT method.
use Curl::easy;
my $curl;
if (($curl = Curl::easy::init()) != 0) {
print "ok\n";
} else {
print "ko\n";
}
Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);
Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);
$url = "http://127.0.0.1/ipfc/broleque.ok";
my @myheaders;
$myheaders[0] = "Server: wrapper-y";
$myheaders[1] = "User-Agent: ipfc-wrap";
sub putdata {
print "calling it or not ?\n";
$x = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZ\nYYYYYYYYYYYYYYYYYYYYYYYY\n";
return $x;
}
Curl::easy::setopt($curl, CURLOPT_WRITEFUNCTION, \&putdata);
Curl::easy::setopt($curl, CURLOPT_HTTPHEADER, \@myheaders);
Curl::easy::setopt($curl, CURLOPT_URL, $url);
Curl::easy::setopt($curl, CURLOPT_CUSTOMREQUEST,"PUT");
if (Curl::easy::perform($curl) != 0) {
print "not ";
};
Curl::easy::cleanup($curl);
close (DESC);
Thanks a lot.
alx
_______________________________________________
Curl-library mailing list
http://curl.haxx.se/libcurl/
Received on 2001-06-22