Sorry I answer so late, I was out of connection a few days :-(
> I won't look at this to closely, the first glance raises enough questions.
> So, a few points, do you really intend an exit with every file served?
> Do you really want your handler to fetch a URL, as a proxy, or should you
> instead redirect to the URL with the query string attached?
The problem is not redirection. The thing is that I want to show an
upper frame in a page requested. The handler prints a frameset and this
frameset requests the page, so the handler is triggered again and I need
to determine whether I just need to print the page and exit or show the
frameset. The deal is that the second time the handler is called, to print
the requested page, it's not doing anything.
> 3) instead of just printing "No good" how about "No good: $requestpage"
> or something else informative about the failure
Yeah, I should. Anyway it's requesting the right page...
Hope you can help me or point me the right way.
> >
> > Hi, I need a script that gets a url, and if it doesn't have a
> > query_string, adds one to the url and requests it again. Then, when it
> > comes with a query, reads the file, print it and exit.
> >
> > The matter is that the script enters a loop as it is requesting pages
> > that trigger the script again. But i've been doing tests with this code
> > and the second time is called, it doesn't print anything and I dunno why.
> > Here's the code:
> >
> > sub handler {
> >
> > my $r = shift;
> > my $uri = $r->parsed_uri;
> > my $query = $uri->query;
> > my $path = $uri->path;
> > my $root = 'http://undertow';
> > # Add a query to the page to request
> > my $requestpage = $root . $path . "?hello";
> > my @pathinfo = split ('/', $path);
> > my $page = $pathinfo[$#pathinfo];
> >
> > if (defined $query) {
> > #r->print("there's a query: $query");
> > # Open the file to send
> > open (FILE, '/var/www/$path');
> > my @data = <FILE>;
> > close(FILE);
> > # Print it and exit
> > $r->print(@data);
> > exit;
> > } else { # The first request enters here
> > my $request = HTTP::Request->new ("GET" => $requestpage);
> > my $response = $ua->request($request);
> > $r->content_type("text/html");
> > $r->send_http_header;
> > if ($response->is_success) {
> > $r->print($response->content);
> > } else {
> > $r->print("No good");
> > }
> >
> > }
> > }
> > 1;
> >
> > If we first request index.html, it goes into else stuff and requests the
> > page as index.html?hello, so it goes through the handler again and should
> > enter the 'if (defined $query)' stuff. Well it actually does but it
> > doesn't return anything: just "No good". ( I've tried printing
> > $r->print("Works\n") instead of $r->print(@data) but it doesn't work
> > neither ). I don't know what's going wrong here and so I'm asking you.
> >
> > TIA for all. Bye!
> >
> >
> >
> >
> >
> >
>
> --
> Salon Internet http://www.salon.com/
> HTTP mechanic, Perl diver, Mebwaster, Some of the above
> Ian Kallen <[EMAIL PROTECTED]> / AIM: iankallen / Fax: (561) 619-0995
>
>