in reply to Re: curl http post using LWP::Curl
in thread curl http post using LWP::Curl

Attempted:

$lwpcurl->{agent}->setopt( CURLOPT_HEADERDATA, ['Content-Type:text/xml +'] );

But get:

libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Can't use an undefined value as filehandle reference at /home/mware/httppost/lib/perl5/site_perl/5.8.8/LWP/Curl.pm lin +e 236 (#1) (F) A value used as either a hard reference or a symbolic referenc +e must be a defined value. This helps to delurk some insidious errors. Uncaught exception from user code: Can't use an undefined value as filehandle reference at /home/ +mware/httppost/lib/perl5/site_perl/5.8.8/LWP/Curl.pm line 236. at /home/mware/httppost/lib/perl5/site_perl/5.8.8/LWP/Curl.pm line 23 +6

This error goes away if I remove that line of code.

Replies are listed 'Best First'.
Re^3: curl http post using LWP::Curl
by Corion (Patriarch) on Jun 11, 2016 at 06:49 UTC

    This error happens in the ->post method of LWP::Curl, a place that doesn't immediately relate to the line you posted above.

    Can you please post a short, self-contained example program that reproduces the problem? Maybe part of the problem is Perl 5.8's spotty support for in-memory filehandles or something else, but without having code to easily reproduce your situation, that's hard to say.

      use LWP::Curl; use Net::Curl::Easy qw(:constants); my $lwpcurl = LWP::Curl->new(); my $referer = 'http://server.com/:5555'; my $post_url = 'http://userid:password@server.com:5555/receive'; open(my $fh, "<", "test.xml"); or die "can not open file ($!)"; $lwpcurl->{agent}->setopt( CURLOPT_READDATA, $fh ); $lwpcurl->{agent}->setopt( CURLOPT_HEADERDATA, ['Content-Type:text/xml +'] ); my $content = $lwpcurl->post($post_url, {}, $referer);