Apache2-Proxy

 view release on metacpan or  search on metacpan

lib/Apache2/Proxy.pm  view on Meta::CPAN

    $r->headers_out->clear();

    $class->translate_cookie_and_auth_headers( $r, $res );

    # Create a hash with the HTTP::Response HTTP::Headers attributes
    $res->scan( sub { $headers{ $_[0] } = $_[1]; } );
    $r->log->debug(
        sprintf( "$$ not cookie/auth headers: %s", Dumper( \%headers ) ) )
      if VERBOSE_DEBUG;

    ## Set the response content type from the request, preserving charset
    $r->content_type( $headers{'Content-Type'} );
    delete $headers{'Content-Type'};

    # need to encode content if utf-8
    my $charset = $class->response_charset($r, $res);
    $r->log->debug("$$ charset is $charset") if DEBUG;
    if (($charset ne 'ISO-8859-1') && ($r->content_type !~ m/image|video/)) {
        $$response_content_ref = Encode::encode($charset,
            $$response_content_ref);
    }       

    #############################
    ## Content languages
    if ( defined $headers{'content-language'} ) {
        $r->content_languages( [ $res->header('content-language') ] );
        $r->log->debug(
            "$$ content languages set to " . $res->header('content_language') )
          if DEBUG;

lib/Apache2/Proxy.pm  view on Meta::CPAN

    # possible through a nasty hack, set the server version
    $r->server->add_version_component( $headers{Server} || 'sl' );

    ###############################
    # maybe someday but not today, do not cache this response
    $r->no_cache(1);

    return 1;
}

# figure out what charset a response was made in, code adapted from
# HTTP::Message::decoded_content
sub response_charset {
    my ( $class, $r, $response ) = @_;

    # pull apart Content-Type header and extract charset
    my $charset;
    my @ct = HTTP::Headers::Util::split_header_words(
        $response->header("Content-Type") );
    if (@ct) {
        my ( undef, undef, %ct_param ) = @{ $ct[-1] };
        $charset = $ct_param{charset};
    }

    # if the charset wasn't in the http header look for meta-equiv
    unless ($charset) {

        # default charset for HTTP::Message - if it couldn't guess it will
        # have decoded as 8859-1, so we need to match that when
        # re-encoding
        return $charset || "ISO-8859-1";
    }
}

sub resolve {
    my ( $class, $hostname ) = @_;

    # run the dns query
    my $query = $Resolver->query($hostname);
    unless ($query) {



( run in 0.320 second using v1.01-cache-2.11-cpan-4d50c553e7e )