Catalyst-View-Reproxy

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

  directory:
    - inc
    - t
requires:
  Catalyst: 0
  Catalyst::View: 0
  Data::Dump: 0
  Fcntl: 0
  File::MMagic: 0
  File::MimeInfo: 0
  HTTP::Request: 0
  HTTP::Response: 0
  LWP::Simple: 0
  LWP::UserAgent: 0
  NEXT: 0
version: 0.05

Makefile.PL  view on Meta::CPAN

abstract('View class for lighty X-SendFile and perlbal X-REPROXY-FILE, X-REPROXY-URL');
version_from('lib/Catalyst/View/Reproxy.pm');
license('perl');

requires('Catalyst');
requires('Catalyst::View');
requires('Catalyst::Plugin::ConfigLoader');
requires('Fcntl');
requires('File::MimeInfo');
requires('File::MMagic');
requires('HTTP::Request');
requires('HTTP::Response');
requires('LWP::Simple');
requires('LWP::UserAgent');
requires('NEXT');

use_test_base;

build_requires('Test::Pod');
build_requires('Test::Pod::Coverage');
build_requires('Test::WWW::Mechanize::Catalyst');

inc/Test/WWW/Mechanize/Catalyst.pm  view on Meta::CPAN


        # *where* do they want us to redirect to?
        my $location = $old_response->header('Location');

        # no-one *should* be returning non-absolute URLs, but if they
        # are then we'd better cope with it.  Let's create a new URI, using
        # our request as the base.
        my $uri = URI->new_abs( $location, $request->uri )->as_string;

        # make a new response, and save the old response in it
        $response = $self->_make_request( HTTP::Request->new( GET => $uri ) );
        my $end_of_chain = $response;
        while ( $end_of_chain->previous )    # keep going till the end
        {
            $end_of_chain = $end_of_chain->previous;
        }                                          #   of the chain...
        $end_of_chain->previous($old_response);    # ...and add us to it
    } else {
        $response->{_raw_content} = $response->content;
        if (   $response->header('Content-Type')
            && $response->header('Content-Type') =~ m/charset=(\S+)/xms )

lib/Catalyst/View/Reproxy.pm  view on Meta::CPAN

package Catalyst::View::Reproxy;

use strict;
use warnings;

use base qw/Catalyst::View/;

use Fcntl;
use File::MimeInfo qw//;
use File::MMagic;
use HTTP::Request;
use HTTP::Response;
use LWP::UserAgent;
use NEXT;

__PACKAGE__->mk_accessors(qw/mmagic/);

=head1 NAME

Catalyst::View::Reproxy - Reproxing View for lighty and perlbal.

lib/Catalyst/View/Reproxy.pm  view on Meta::CPAN

            $c->response->header( 'X-REPROXY_EXPECTED_SIZE', $expected_size );
        }
    }
    else {
        my $rand_url = $url->[ int( rand( scalar @{$url} ) ) ];

        my $ua = LWP::UserAgent->new;
        $ua->timeout( int $self->config->{timeout} )
          if ( $self->config->{timeout} );

        my $req = HTTP::Request->new( GET => $rand_url );
        $req->header( 'Accept' => '*' );
        my $res = $ua->request($req);

        if ( $res->is_success ) {
            my $content = $res->content;

            unless ( $c->response->content_type ) {
                if ( $self->mmagic ) {
                    $c->response->content_type(
                        $self->mmagic->checktype_contents($content) );



( run in 0.412 second using v1.01-cache-2.11-cpan-de7293f3b23 )