Re: 500 Internet error problems

Roland Bauer (roland.bauer@fff.at)
Wed, 28 Oct 1998 09:28:18 +0100


Hello Ryan,

I think you first have to create a user agent like described in LWP.pm.
(You can get this info with command "perldoc LWP".)

The one example you give just seems :-) to work.

THIS WORKS: (no 500, though blank)
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
#use LWP;
$url = "http://www.perl.com";
$in = get($url);
print $in;

Because it's like:

#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print ""; # or maybe print undef

Roland


(Please see snippet below.)

#----------
=head2 An Example

This example shows how the user agent, a request and a response are
represented in actual perl code:

  # Create a user agent object
  use LWP::UserAgent;
  $ua = new LWP::UserAgent;
  $ua->agent("AgentName/0.1 " . $ua->agent);

  # Create a request
  my $req = new HTTP::Request POST =>
'http://www.perl.com/cgi-bin/BugGlimpse';
  $req->content_type('application/x-www-form-urlencoded');
  $req->content('match=www&errors=0');

  # Pass request to the user agent and get a response back
  my $res = $ua->request($req);

  # Check the outcome of the response
  if ($res->is_success) {
      print $res->content;
  } else {
      print "Bad luck this time\n";
  }

The $ua is created once when the application starts up.  New request
objects are normally created for each request sent.
#------------

Ryan Retting wrote:

> I'm getting 500 Internet error problems.
> It will run on the command line and not through MSIE or LYNX and yes there
> is a print "Content-type: text/html\n\n"; line.
>
> Through hours and hours of trying to get it to work, i've concluded that
> whenever i try any form of use LWP; I'll get a 500 error.
>
> A possibly related thing is that LWP, Data-Dumper, HTML-Parser, MD5,
> MIME-64, etc. are all installed (and reinstalled many times 100%
> successfully through all tests) in ~/perl.  I used the perl Makefile.PL
> PREFIX=~/perl LIB=~/perl
> command when installing these.
>
> I also have PERL5LIB=~/perl in my env.
>
> THIS DOES NOT WORK:
> #!/usr/local/bin/perl
> print "Content-type: text/html\n\n";
> use LWP;
> $url = "http://www.perl.com";
> $in = get($url);
> print $in;
>
> THIS WORKS: (no 500, though blank)
> #!/usr/local/bin/perl
> print "Content-type: text/html\n\n";
> #use LWP;
> $url = "http://www.perl.com";
> $in = get($url);
> print $in;
>
> THIS DOES NOT WORK:
> #!/usr/local/bin/perl
> print "Content-type: text/html\n\n";
> use LWP ;
> print "hello";
>
> THIS DOES WORK:
> #!/usr/local/bin/perl
> print "Content-type: text/html\n\n";
> print "Hello";
>
> THIS DOES NOT WORK (~/perl = /home/cscstd/qurst/rretting/perl):
> #!/usr/local/bin/perl
> print "Content-type: text/html\n\n";
> use LWP "/home/cscstd/qrst/rretting/perl";
> $url = "http://www.perl.com";
> $in = get($url);
> print $in;
>
> THIS DOES NOT WORK:
> #!/usr/local/bin/perl
> print "Content-type: text/html\n\n";
> use lib "home/cscstd/qrst/rretting/perl";
> use LWP;
> $url = "http://www.perl.com";
> $in = get($url);
> print $in;
>
> hopefully those examples helped.
> thanks!
>       -Ryan
>
> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
> ROCK - ICQ#9082094
> rretting@calpoly.edu
> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\



--
roland.bauer@fff.at        +43-(1)-33-421-88  (home)
http://www.fff.at/fff/     +43-(1)-536-06/537 (work)