Any-Daemon-HTTP
view release on metacpan or search on metacpan
lib/Any/Daemon/FCGI/ClientConn.pm view on Meta::CPAN
package Any::Daemon::FCGI::ClientConn;
use vars '$VERSION';
$VERSION = '0.30';
use warnings;
use strict;
use Log::Report 'any-daemon-http';
use HTTP::Request ();
use Time::HiRes qw(usleep);
use Errno qw(EAGAIN EINTR EWOULDBLOCK);
use IO::Select ();
use Socket qw/inet_aton PF_INET AF_INET SHUT_RD SHUT_WR/;
use Any::Daemon::FCGI::Request ();
use constant
{ FCGI_VERSION => 1
, FCGI_KEEP_CONN => 1 # flag bit
lib/Any/Daemon/FCGI/ClientConn.pm view on Meta::CPAN
# It depends on the $status code which additionals fields were sent.
sub _fcgi_end_request($$;$)
{ my ($self, $status, $req_id, $rc) = @_;
my $body = pack "nCCCC", $rc || 0, $end_status2id{$status}
, RESERVED, RESERVED, RESERVED;
$self->_reply_record(END_REQUEST => $req_id, $body);
}
# Convert the FGCI request into a full HTTP::Request object
sub _body2hash($$)
{ my ($self, $body) = @_;
my %h;
while(length $$body)
{ my $name_len = $self->_take_encoded_nv($body);
my $value_len = $self->_take_encoded_nv($body);
my $name = substr $$body, 0, $name_len, '';
$h{$name} = substr $$body, 0, $value_len, '';
lib/Any/Daemon/FCGI/ClientConn.pod view on Meta::CPAN
=back
=head2 HTTP
=over 4
=item $obj-E<gt>B<my>($request = $client->get_request;)
Returns the next L<Any::Daemon::FCGI::Request|Any::Daemon::FCGI::Request> object (which is a simple
extension to HTTP::Request). Maintenance records which are in the
incoming stream are handled as well.
=back
=head1 SEE ALSO
This module is part of Any-Daemon-HTTP distribution version 0.30,
built on April 06, 2020. Website: F<http://perl.overmeer.net/any-daemon/>
=head1 LICENSE
lib/Any/Daemon/FCGI/Request.pm view on Meta::CPAN
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.02.
# This code is part of distribution Any-Daemon-HTTP. Meta-POD processed
# with OODoc into POD and HTML manual-pages. See README.md
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
package Any::Daemon::FCGI::Request;
use vars '$VERSION';
$VERSION = '0.30';
use base 'HTTP::Request';
use warnings;
use strict;
use Log::Report 'any-daemon-http';
sub new($)
{ my ($class, $args) = @_;
my $params = $args->{params} or panic;
lib/Any/Daemon/FCGI/Request.pod view on Meta::CPAN
=encoding utf8
=head1 NAME
Any::Daemon::FCGI::Request - HTTP::Request with little extras
=head1 INHERITANCE
Any::Daemon::FCGI::Request
is a HTTP::Request
=head1 SYNOPSIS
# Instantiated by Any::Daemon::FCGI::ClientConn
=head1 DESCRIPTION
In the FCGI protocol, the web-site user's HTTP request is accompanied
by some additional information about the front-end web-server. Also,
the headers are processed into parameters C<HTTP_*> and the body is
fed to STDIN. The first thing this FCGI implementation does, is
undoing this mutilation: bringing back a HTTP::Request. The
additional information is provided via some additional attributes.
=head1 METHODS
=over 4
=item Any::Daemon::FCGI::Request-E<gt>B<new>(%options)
Create a new request object. This method is called by
L<Any::Daemon::FCGI::ClientConn|Any::Daemon::FCGI::ClientConn> each time it has collected all the data
lib/Any/Daemon/HTTP.pod view on Meta::CPAN
=head2 Server supported features
Many often used features are supported
=over 4
=item * HTTP/1.1 protocol
Supported by via the HTTP::Daemon connection implementation, which
is gracefully hijacked. Messages are HTTP::Request and HTTP::Response
objects, borrowed from LWP.
=item * virtual hosts
Multiple "hosts" listening on the same port, abstracted in
L<Any::Daemon::HTTP::VirtualHost|Any::Daemon::HTTP::VirtualHost> objects. The vhosts have a
name and may have a number of aliases.
=item * directories per VirtualHost
lib/Any/Daemon/HTTP/Source.pod view on Meta::CPAN
sub allow($$$)
{ my ($self, $session, $request, $uri) = @_;
# General rules may refuse access already
$self->SUPER::allow($session, $request, $uri)
or return 0;
# here your own checks
# $session is a Any::Daemon::HTTP::Session
# $request is a HTTP::Request
# $uri is a URI::
1;
}
You may also pass a code-ref to L<new(allow)|Any::Daemon::HTTP::Source/"Constructors">:
my $vhost = Any::Daemon::HTTP::VirtualHost
->new(allow => \&my_rules, ...);
lib/Any/Daemon/HTTP/VirtualHost.pod view on Meta::CPAN
my $resp = $vhost->$method($session, $req, $uri, $tree);
In which
=over 4
=item * C<$vhost> is an C<Any::Daemon::HTTP::VirtualHost>,
=item * C<$session> is an L<Any::Daemon::HTTP::Session|Any::Daemon::HTTP::Session>,
=item * C<$req> is an HTTP::Request,
=item * C<$uri> an URI after rewrite rules, and
=item * C<$tree> the selected C<Any::Daemon::HTTP::Directory>.
=back
The handler could work like this:
sub formHandler($$$$)
( run in 0.441 second using v1.01-cache-2.11-cpan-de7293f3b23 )