impossiblerobot has asked for the wisdom of the Perl Monks concerning the following question:
Being completely flustered, I once again turn to the Monastery for help:
I am using LWP::UserAgent to post to a couple of secure servers. When I post to the test server, everything works just fine. When I post to the production server, the script dies with the following error:
Can't call method "request" on an undefined value at /usr/lib/perl5/si +te_perl/5.6.0/LWP/UserAgent.pm line 362.
(It appears that the useragent object is somehow disappearing.) The only difference between the two runs is the URL. I've tried running the same script from another server with the same versions of LWP, HTTP::Request, etc., and both passes seem to work right. The code I am running is very simple:
#!/usr/bin/perl -w use strict; use CGI::Carp qw( fatalsToBrowser ); require LWP::UserAgent; use HTTP::Request; use HTTP::Headers; print "Content-type: text/html\n\n"; my $ua = new LWP::UserAgent; my $content = 'Content'; my $URL = 'https://some.address.here'; my $headers = HTTP::Headers->new( MIME_version => '1.0', Content_type => 'application/PTI9', Content_length => length($content), Content_transfer_encoding => 'text', Request_number => 1, Document_type => 'Request', ); print <<"EOH"; <html> <head><title>LWP Test</title></head> <body> <h2>Request</h2> <pre> EOH my $request = HTTP::Request->new(POST => $URL, $headers, $content); print $request->as_string(); print <<"EOH"; </pre> <h2>Response</h2> <pre> EOH my $response = $ua->request($request); if ($response->is_success) { print $response->content; } else { print $response->error_as_HTML; } print <<"EOH"; </pre><h2>Completed</h2> </body></html> EOH exit;
and here are the results of an LWP::Debug trace from the failed attempt(s):
LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: POST https://some.adddress.here LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () Can't call method "request" on an undefined value at /usr/lib/perl5/si +te_perl/5.6.0/LWP/UserAgent.pm line 362.
I've searched the Monastery and Google, but haven't found a solution. I would appreciate any help my fellow monks can give.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP dies calling request method
by tstock (Curate) on Aug 03, 2002 at 19:18 UTC | |
by impossiblerobot (Deacon) on Aug 03, 2002 at 20:03 UTC | |
|
Re: LWP dies calling request method
by valdez (Monsignor) on Aug 03, 2002 at 20:56 UTC | |
|
Re: LWP dies calling request method
by insensate (Hermit) on Aug 03, 2002 at 21:51 UTC | |
by impossiblerobot (Deacon) on Aug 03, 2002 at 22:38 UTC | |
by valdez (Monsignor) on Aug 03, 2002 at 22:47 UTC |