perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Iosif Fettich <>
Subject who's putting that <pre> tag in the output...?
Date Mon, 23 Mar 2009 08:10:34 GMT
Dear all,

as I'm still making no progress in finding what's up, I thought I'll try 
to ask for some help.

I wrote a little PerlResponse header, like

package Apache::Default_to_OLD;

use strict;
use warnings;

use Apache2::Const -compile => qw(OK DECLINED);
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::RequestUtil ();
use Apache2::SubRequest;
use APR::URI;
use Apache2::URI;
use HTTP::Request;
use LWP::UserAgent;

sub handler {
     my $r = shift;

     if ($r->is_initial_req) {
         my $unparsed_uri = $r->unparsed_uri();
         my $subr = $r->lookup_uri( $unparsed_uri );
         my $rc = $subr->run;
         if ($rc eq Apache2::Const::OK) {
            # the new site is offering what is wanted
            return $rc;
         else {
             # transform the request into a proxy request
             my $url  = $r->construct_url;
             my $args = $r->args();
             my $full_url = $url;
                $full_url .= "?$args" if defined $args;
             my $parsed = APR::URI->parse($r->pool, $full_url);
                $parsed->hostname( '' );
             my $new_url = $parsed->unparse;

             # Create a new request.
             my $request = HTTP::Request->new( GET => $new_url );

             # Pass the request to the user agent and get a response back.
             my $response = LWP::UserAgent->new->request($request);
             my $content = $response->content;
             print  $content;
             return Apache2::Const::OK if $response->is_success;
             return $response->code;
     return Apache2::Const::DECLINED;


The problem is that what I want to be the handler's proxied response is 
actual embedded instead in an construct like



which I seem not to be able to get rid of. What am I doing wrong..?

What I want to achieve is that I'd want to allow for gradually replacement 
of the content for an existing site. Customers and search engines should 
_not_ be redirected to new URLs. The new content, if available, seems to 
be served OK, but the old content, which should be served when there is 
not yet any new content available, is shown as source, inside those <pre> 

Are there any obvious/better ways to get the functionality I hope to get ?

Thanks in advance,

Iosif Fettich

View raw message