HTTP-Proxy-Selective

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

no_index:
  directory:
    - inc
    - t
requires:
  Config::Tiny: 0
  File::Slurp: 0
  File::Temp: 0
  HTTP::Headers: 1.64
  HTTP::Proxy: 0.22
  IO::Socket::SSL: 0
  Net::SSLeay: 0
  Path::Class: 0
resources:
  license: http://opensource.org/licenses/mit-license.php
version: 0.004

Makefile.PL  view on Meta::CPAN

use warnings;
use inc::Module::Install 0.91;

all_from 'lib/HTTP/Proxy/Selective.pm';

license 'mit';

requires 'HTTP::Proxy' => 0.22;
requires 'File::Slurp';
requires 'File::Temp';
requires 'IO::Socket::SSL';
requires 'Net::SSLeay';
requires 'Path::Class';
requires 'Config::Tiny';
requires 'HTTP::Headers' => '1.64'; # ->if_modified_since method.
build_requires 'Test::MockObject';

auto_install();

install_script 'script/selective_proxy';
#build_exe('selective_proxy');

script/selective_proxy  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Proxy;
use Config::Tiny;
use HTTP::Proxy::Selective;
use LWP::UserAgent;
use IO::Socket::SSL;
use IO::Socket::INET;
use Net::SSLeay;
use File::Temp;

# For PAR
my $sep = '/';
if ($^O =~ /WIN32/i) {
    $sep = "\\";
}
require join($sep, qw/HTTP Proxy Engine NoFork.pm/);

script/selective_proxy  view on Meta::CPAN

    # send the response headers (FIXME more headers required?)
    my $response = HTTP::Response->new(200);
    $self->response($response);
    $self->{$_}{response}->select_filters( $response ) for qw( headers body );

    $self->_send_response_headers( $served );

    # we now have a TCP connection to the upstream host
    $last = 1;
    my $class = ref($conn);
    { no strict 'refs'; unshift(@{$class . "::ISA"}, 'IO::Socket::SSL'); } # Forcibly change classes the socket inherits from
    $class->start_SSL($conn, 
        SSL_server => 1, 
        SSL_key_file => $key,
        SSL_cert_file => $cert, # Turn our client socket into SSL.
    ) or warn("Could not start SSL");
    ${*$conn}{'httpd_nomore'} = 0; # Pay no attention to the Connection: close header behind the curtain.
    {   # Build a method to fiddle with the request object we get from the client, as it needs to http->https
        my $old_setrequest_method = \&HTTP::Proxy::request;
        my $new_request_method = sub {
            my ($self, $new_req) = @_;



( run in 0.368 second using v1.01-cache-2.11-cpan-05444aca049 )