1package HTTP::Proxy::Engine::NoFork; 2use strict; 3 4our @ISA = qw( HTTP::Proxy::Engine ); 5 6__PACKAGE__->make_accessors( 'select' ); 7 8sub start { 9 my $self = shift; 10 my $proxy = $self->proxy; 11 12 $self->select( IO::Select->new( $proxy->daemon ) ); 13 14 # clients will not block the proxy by keeping the connection open 15 $proxy->max_keep_alive_requests( 1 ); 16} 17 18sub run { 19 my $self = shift; 20 my $proxy = $self->proxy; 21 22 # check for new connections 23 for my $fh ( $self->select->can_read() ) { # there's only one, anyway 24 25 # single-process proxy 26 $proxy->serve_connections( $fh->accept ); 27 $proxy->new_connection; 28 } 29} 30 311; 32 33__END__ 34 35=head1 NAME 36 37HTTP::Proxy::Engine::NoFork - A basic, non forking HTTP::Proxy engine 38 39=head1 SYNOPSIS 40 41 use HTTP::Proxy; 42 my $proxy = HTTP::Proxy->new( engine => 'NoFork' ); 43 44=head1 DESCRIPTION 45 46The L<HTTP::Proxy::Engine::NoFork> engine runs the proxy without forking. 47 48=head1 METHODS 49 50=over 4 51 52=item start() 53 54Initialise the engine. 55 56=item run() 57 58Implements the non-forking logic by calling C<< $proxy->serve_requests() >> 59directly. 60 61=back 62 63=head1 SEE ALSO 64 65L<HTTP::Proxy>, L<HTTP::Proxy::Engine>. 66 67=head1 AUTHOR 68 69Philippe "BooK" Bruhat, C<< <book@cpan.org> >>. 70 71=head1 COPYRIGHT 72 73Copyright 2005-2013, Philippe Bruhat. 74 75=head1 LICENSE 76 77This module is free software; you can redistribute it or modify it under 78the same terms as Perl itself. 79 80=cut 81 82