curl-users
Re: libcurl-7.8 PUT problem
Date: Fri, 15 Jun 2001 12:33:26 +1000
Hi (Samuel?),
I'd like to look into your perl problem - can you try changing:
my $fh_in = new IO::File || die "error: $!\n";
$fh_in->open("<$file") || die "error: $!\n";
from using IO::File to using a 'normal' perl GLOB:
open FH_IN,"<$file" or die "error: $!\n";
and then try using FH_IN instead of $fh_in in your CURLOPT_INFILE
setting?
I suspect the problem is that the new Curl::easy has 'smarts' to deal
with the curl callback feature for perl functions, which is being
confused, as you are setting a callback file handle (opaque pointer)
which is not a GLOB, but then not supplying a perl callback function.
The default STDIO 'write' function actually MUST have a FILE * pointer
passed to it, which Curl::easy attempts to make from a GLOB, but that is
probably not going to work if you just pass in some perl object ref.
I can't work on this straight away, but if you can answer this, it will
help me when I do get to look into it properly...
Cris
Souk-Aloun Samuel wrote:
>
> >
> > It might help if you would show us:
> >
> > - Your curl command line/script
> > - What happens exactly
> > - Does the server respond anything?
> > - What Linux version?
> > - Any other details you think might help us track this down.
> >
> > A segfault is *never* the expected behaviour.
> >
> > --
> > Daniel Stenberg -- curl dude -- http://curl.haxx.se/
>
> ok, it's a little bit complicated to describe everything because I have
> three different platforms and different behaviours too, so, I will focus
> on a problem which is common to all platforms:
>
> - the perl script is exiting with segfault (at perform())
> - the cgi script get the correct content-length but no data
> - the PUT works when I use LWP::UserAgent & HTTP::Request
> - the PUT works when I use curl-7.6 & Curl::easy 1.0.2 (with the
> "curl_easy_" prefix)
>
> NB: I have the curl command working properly
> /usr/local/bin/curl -u xxx:xxx -T test.xfer --url
> http://koyao/upload/test.xfer -D head.out
>
> - client platform: linux-2.4.3 (mandrake 8.0)
> curl-7.8
> Curl-easy-1.1.5
> glibc-2.2.2
> gcc-2.96
> perl-5.600
>
> - server platform: linux-2.2.19 (mandrake 7.2)
> apache-1.3.14
>
> ----<the perl script>----
> #!/usr/bin/perl
>
> use strict;
> use vars qw($errbuf);
> use Curl::easy;
> use IO::File;
>
> my $url = "http://koyao/upload/test.xfer";
> my $file = './test.xfer';
> my ($user, $passwd) = ('xxx', 'xxx');
>
> my $fh_in = new IO::File || die "error: $!\n";
> $fh_in->open("<$file") || die "error: $!\n";
> my $filesize = -s $file;
>
> my $curl = Curl::easy::init();
> Curl::easy::setopt($curl, Curl::easy::CURLOPT_URL, $url);
> Curl::easy::setopt($curl, Curl::easy::CURLOPT_INFILE, $fh_in);
> Curl::easy::setopt($curl, Curl::easy::CURLOPT_INFILESIZE, $filesize);
> Curl::easy::setopt($curl, Curl::easy::CURLOPT_PUT, 1);
> Curl::easy::setopt($curl, Curl::easy::CURLOPT_NOPROGRESS, 1);
> Curl::easy::setopt($curl, Curl::easy::CURLOPT_MUTE, 1);
> Curl::easy::setopt($curl, Curl::easy::CURLOPT_TIMEOUT, 30);
> Curl::easy::setopt($curl, Curl::easy::CURLOPT_USERPWD, "$user:$passwd");
> Curl::easy::setopt($curl, Curl::easy::CURLOPT_ERRORBUFFER, "errbuf");
>
> if (Curl::easy::perform($curl) == 0) {
> my ($bytes, $realurl, $httpcode);
> Curl::easy::getinfo($curl, Curl::easy::CURLINFO_SIZE_DOWNLOAD,
> $bytes);
> print "ok: $bytes bytes read\n";
> Curl::easy::getinfo($curl, Curl::easy::CURLINFO_EFFECTIVE_URL,
> $realurl);
> Curl::easy::getinfo($curl, Curl::easy::CURLINFO_HTTP_CODE,
> $httpcode);
> print "effective fetched url (http code: $httpcode) was: $url\n";
> } else {
> print "not ok: '$errbuf'\n";
> }
>
> $fh_in->close;
> Curl::easy::cleanup($curl);
>
> ----</the perl script>----
>
> this is the same if I use "CURLOPT_UPLOAD, 1" or "CURLOPT_CUSTOMREQUEST,
> 'PUT'" instead of "CURLOPT_PUT, 1"
Received on 2001-06-15