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

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

From: Stas Bekman
Subject: Re: Can't retrieve page I just created with LWP under mod_perl
Date: 13:39 on 09 May 2005
Dan Horne wrote:
> I've written a small CGI::Application CMS that publishes content to flat
> files via. The file-type can be any that the designers decide, but generally
> it will be something that supports includes such as SSI or PHP. This is fine
> most of the time but occasionally I need to produce dynamic pages - e.g. a
> search result. 
> 
> To do this, I generate the search result php/shtml page to the file system,
> and then request it from the web server using LWP:
> 
>     my $file = $self->get_value('cms_document_root') . "/" . $page;
>     $self->logger->debug("Creating $file");
>     
>     # write the results to the temporary file
>     open(FH, ">$file") || die "Cannot create $file";
>     print FH $template->output();
>     close FH || die "Cannot close $file";    
>     $self->logger->debug("Created $file");
>     
>     # request the temporary file 
>     my $request_page = "http://"; . $ENV{SERVER_NAME} .
>         $self->get_value('cms_publish_url') . "/$page";
>     $self->logger->debug("request_page: $request_page");
>     my $agent        = LWP::UserAgent->new;
>     my $request      = HTTP::Request->new(GET => $request_page);
> 
> 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.

Not sure if there is something specific under win32, but mod_perl differs 
from mod_cgi since:

1) it is running under the same username the server runs with
2) the environment persists

In the script above, you don't use LWP, you create an agent, but you don't 
use it. I can't see where the actual request is.

        -- 
        __________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxx.xxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: Can't retrieve page I just created with LWP under mod_perl
Stas Bekman 13:39 on 09 May 2005

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