I can't get LWP::UserAgent to run correctly under modperl, but I can make it
work from the command line or as a regular CGI.
The test script: (don't laugh at my funny coding, I usually use HTML::Mason
these days)
#!/usr/bin/perl -w
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use Data::Dumper;
use CGI;
use strict;
use vars qw ($q);
$q = new CGI;
$q->print($q->header);
main();
sub main {
my $url = 'http://www.perl.com/cgi-bin/cpan_mod';
my $timeout = 15;
my $ua = LWP::UserAgent->new();
$ua->timeout($timeout);
dodump($ua);
my $req = POST $url, [ module => 'DB_File', readme => 1 ];
dodump($req);
my $resp = $ua->request($req);
dodump($resp);
my $content = $resp->as_string;
$q->print($content);
}
sub dodump {
my $var = shift;
$q->print('<pre>' . Dumper($var) . '</pre>');
}
--------
Most of the output if run as a CGI:
...
$VAR1 = bless( {
'_request' => bless( {
'_method' => 'POST',
'_content' =>
'module=DB_File&readme=1',
'_headers' => bless( {
'content-length' => 23,
'content-type' => 'application/x-www-form-urlencoded',
'user-agent'
=> 'libwww-perl/5.46'
},
'HTTP::Headers' ),
'_uri' => bless( [
bless( do{\(my $o
= 'http://www.perl.com/cgi-bin/cpan_mod')}, 'URI::http' ),
undef
], 'URI::URL' )
}, 'HTTP::Request' ),
'_protocol' => 'HTTP/1.1',
'_content' => '',
'_headers' => bless( {
'client-peer' =>
'208.201.239.50:80',
'connection' => 'close',
'location' =>
'http://www.perl.com/CPAN-local/authors/id/PMQS/DB_File-1.71.readme',
'client-date' => 'Tue, 21 Dec 1999
17:44:46 GMT',
'content-type' => 'text/plain',
'date' => 'Tue, 21 Dec 1999 17:44:42
GMT',
'server' => 'Apache/1.3.6 (Unix)'
}, 'HTTP::Headers' ),
'_rc' => 302,
'_msg' => 'Moved'
}, 'HTTP::Response' );
HTTP/1.1 302 (Found) Moved Connection: close Date: Tue, 21 Dec 1999 17:44:42
GMT Location:
http://www.perl.com/CPAN-local/authors/id/PMQS/DB_File-1.71.readme Server:
Apache/1.3.6 (Unix) Content-Type: text/plain Client-Date:
Tue, 21 Dec 1999 17:44:46 GMT Client-Peer: 208.201.239.50:80
------------
most of the output if run under Apache::Registry:
$VAR1 = bless( {
'_method' => 'POST',
'_content' => 'module=DB_File&readme=1',
'_headers' => bless( {
'content-length' => 23,
'content-type' =>
'application/x-www-form-urlencoded'
}, 'HTTP::Headers' ),
'_uri' => bless( [
bless( do{\(my $o =
'http://www.perl.com/cgi-bin/cpan_mod')}, 'URI::http' ),
undef
], 'URI::URL' )
}, 'HTTP::Request' );
$VAR1 = bless( {
'_request' => bless( {
'_method' => 'POST',
'_content' =>
'module=DB_File&readme=1',
'_headers' => bless( {
'content-length' => 23,
'content-type' => 'application/x-www-form-urlencoded',
'user-agent'
=> 'libwww-perl/5.46'
},
'HTTP::Headers' ),
'_uri' => bless( [
bless( do{\(my $o
= 'http://www.perl.com/cgi-bin/cpan_mod')}, 'URI::http' ),
undef
], 'URI::URL' )
}, 'HTTP::Request' ),
'_content' => '',
'_headers' => bless( {
'client-date' => 'Tue, 21 Dec 1999
17:46:19 GMT'
}, 'HTTP::Headers' ),
'_rc' => 500,
'_msg' => 'Can\'t call method "new" without a package or
object reference'
}, 'HTTP::Response' );
500 (Internal Server Error) Can't call method "new" without a package or
object reference Client-Date: Tue, 21 Dec 1999 17:46:19 GMT
---------
The line where it dies is here (warnings added by me) in
LWP::Protocol::http. I never get the second warning under Registry.
warn "CREATING SELECT with $socket";
my $sel = IO::Select->new($socket) if $timeout;
warn "SELECT CREATED";
---
Here is my configuration:
Linux linux419.dn.net 2.2.13 #2 Sat Nov 27 15:46:06 EST 1999 i686 unknown
Server Version: Apache/1.3.9 (Unix) mod_perl/1.21
perl -V :
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
Platform:
osname=linux, osvers=2.2.11, archname=i686-linux
uname='linux linux419.dn.net 2.2.11 #3 tue sep 14 09:12:37 edt 1999 i686
unknown '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='gcc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux
(egcs-1.1.2 release)
cppflags='-Dbool=char -DHAS_BOOL'
ccflags ='-Dbool=char -DHAS_BOOL'
stdchar='char', d_stdstdio=undef, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
libc=, so=so, useshrplib=true, libperl=libperl.so
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-rdynamic -Wl,-rpath,/usr/local/lib/perl5/5.00503/i686-linux/CORE
'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under linux
Compiled at Sep 15 1999 12:36:14
%ENV:
PERL5LIB="/home/stage/irama/modules"
PERLLIB="/home/stage/irama/modules/"
@INC:
/home/stage/irama/modules
/usr/local/lib/perl5/5.00503/i686-linux
/usr/local/lib/perl5/5.00503
/usr/local/lib/perl5/site_perl/5.005/i686-linux
/usr/local/lib/perl5/site_perl/5.005
.
----------
I've seen this work on a server with
useshrplib=false, libperl=libperl.a
Is that likely to be my problem here?
--
Barry Hoggard
http://www.investorama.com
voice: 212-741-7954
email: [EMAIL PROTECTED]