POE-XUL

 view release on metacpan or  search on metacpan

lib/POE/Component/XUL.pm  view on Meta::CPAN

    local $self->{response} = $resp;

    $self->parse_args( $req );

    my $uri_restart = $self->uri_restart;
    my $content = <<TEXT;
uri_restart: $uri_restart
TEXT
    xwarn "content=$content";
    $resp->code( RC_OK );
    $resp->content_type( 'text/plain' );
    $resp->content_length( length $content );
    $resp->content( $content );
    return RC_OK;
}






############################################################################
# Log handling

############################################################
sub build_logging
{
    my( $self, $args_log ) = @_;

    $self->{logging} = POE::XUL::Logging->new( $args_log, $self->{log_root} );
}

############################################################
sub log_setup
{
    my( $self ) = @_;
    $self->{logging}->setup;
}

############################################################
sub sig_HUP
{
    my( $self ) = @_;
    xwarn "SIGHUP";
    $poe_kernel->sig_handled();

    $self->log_setup;
}


############################################################
sub post_connection
{
    my( $self, $req, $resp ) = @_;
    my $app = eval { $req->param( 'app' ) } || $self->{logging}->{app};
    local $self->{logging}->{app} = $app;

    my $conn = $req->connection;
    my @log;
    push @log, ($conn ? $conn->remote_ip : '0.0.0.0');
    if( $log[-1] eq '127.0.0.1' and $req->header( 'X-Forwarded-For' ) ) {
        $log[-1] = $req->header( 'X-Forwarded-For' );
    }
    # push @log, ($self->{preforked} ? $$ : '-');
    push @log, $$, '-';

    

    my $path = $req->uri->path;
    my $query = $req->uri->query;
    $path .= "?$query" if $query and $req->method eq 'GET';

    push @log, "[". POSIX::strftime("%d/%m/%Y:%H:%M:%S %z", localtime)."]",
               join ' ', $req->method, $path;
    $log[-1] = qq("$log[-1]");
    push @log, ($resp->code||'000'), ($resp->content_length||0);

    xlog( { message => join( ' ', @log )."\n",
            type    => 'REQ'
        } );
#    use Devel::Cycle;
#    find_cycle( $poe_kernel );
    return RC_OK;
}




1;

__END__

=head1 NAME

POE::Component::XUL - POE::XUL server

=head2 SYNOPSIS

    use POE;
    use POE::Component::XUL;

    POE::Component::XUL->spawn( { 
                                    port => 8001,
                                    root => '/var/poe-xul/',
                                    alias => 'POE-XUL',
                                    opts  => {},
                                    timeout => 30 * 60,
                                    logging => {},
                                    apps => {   
                                        MyApp => 'My::App',
                                        # ....
                                    } 
                              } );
    $poe_kernel->run();

=head1 DESCRIPTION

POE::Component::XUL handles all POE and HTTP events for a POE::XUL server.

POE::Component::XUL creates an HTTP server with
L<POE::Component::Server::HTTP>.



( run in 3.165 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )