RE: Can't retrieve page I just created with LWP under mod_perl

[prev] [thread] [next] [Date index for 2005/05/10]

From: Randy Kobes
Subject: RE: Can't retrieve page I just created with LWP under mod_perl
Date: 03:38 on 10 May 2005
On Tue, 10 May 2005, Dan Horne wrote:

> > > > This works fine under standard CGI, but the LWP
> > > > request times out under mod_perl. The temporary page
> > > > name is random, so I know that it's not a file
> > > > conflict.
> > > >
> > > > Have I missed something? I'm using Apache 1.3.31 and
> > > > mod_perl 1.29 on Windows XP, but whatever I do has
> > > > to also work under vanilla CGI.
>
> Ok, I've determined that it works fine under Linux,
> mod_perl and Apache 1.3.33, so I assume that it's a
> problem with Windows. That's a shame, because I typically
> develop on Windows, but I guess that since I'm deploying
> to Linux, I can live with things

It might be that, on Windows, you're running into the
multithreading limitations of mod_perl 1:
http://perl.apache.org/docs/1.0/os/win32/multithread.html
which means that one request must finish before another
one can be handled. For example, this mod_perl registry
script:
=====================================================
use strict;
use warnings;
use LWP;
use File::Spec;
my $htdocs = 'D:/Apache2/htdocs';
my $file = 'log.txt';
my $abs_file = File::Spec->catfile($htdocs, $file);
open(my $fh, '>', $abs_file) or die "Cannot open $abs_file: $!";
print $fh "This is a test";
close $fh;
my $request_page = 'http://' . $ENV{SERVER_NAME} . "/$file";
my $agent = LWP::UserAgent->new;
my $request = HTTP::Request->new(GET => $request_page);
my $response = $agent->request($request);
print "Content-type: text/plain\n\n";
if ($response->is_success) {
  print "Received content of " . $response->content;
}
else {
  print "Something went wrong ...";
}
============================================================
fails for me under mod_perl 1 on Win32, but works fine
with mod_perl 2. Do you have the option to upgrade your
Windows system to use mod_perl 2/Apache 2?

        -- 
        best regards,
randy kobes

RE: Can't retrieve page I just created with LWP under mod_perl
Randy Kobes 03:38 on 10 May 2005

Generated at 06:56 on 17 May 2005 by mariachi v0.52