GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  POEX::ROLE::PSGISERVER (3)

.ds Aq ’

NAME

POEx::Role::PSGIServer - Encapsulates core PSGI server behavior

CONTENTS

VERSION

version 1.110670

SYNOPSIS



    use MooseX::Declare;
    class MyServer with POEx::Role::PSGIServer { }

    MyServer->new()->run($some_psgi_app);



DESCRIPTION

POEx::Role::PSGIServer encapsulates the core PSGI server behaviors into an easy to consume and extend role. It is based on previous POEx work such as POEx::Role::TCPServer which provides basic TCP socket multiplexing via POE::Wheel::SocketFactory and POE::Wheel::ReadWrite, and POEx::Role::SessionInstantiation which transforms plain Moose objects into POE sessions.

    RATIONALE

This Role has its roots firmly planted in POE::Component::Server::PSGI which provided the initial seed with the layout and logic of the basic server. Unfortunately, POE::Component::Server::PSGI didn’t provide any mechnism for extension. The main goal of this Role is to provide as many extension points as possible. The secondary goal is to provide a more reasonable abstraction for several key pieces of the stack for streaming, and push writing.

CLASS_METHODS

    around BUILDARGS



    (ClassName $class: @args)



BUILDARGS is wrapped to translate from the expected Plack::Handler interface to POEx::Role::TCPServer’s expected interface.

PUBLIC_ATTRIBUTES

    psgi_app



    is: ro, isa: CodeRef, writer: register_service



This attribute stores the PSGI application to be run from this server. A writer method is provided to match the expected Plack::Handler interface

PROTECTED_ATTRIBUTES

    wheel_flushers



    is: ro, isa: HashRef,
    exists : has_wheel_flusher,
    get    : get_wheel_flusher,
    set    : set_wheel_flusher,
    delete : clear_wheel_flusher



This attribute stores coderefs to be called on a wheel’s flush event (necessary to properly handle poll_cb)

PUBLIC_METHODS

    run



    (CodeRef $app)



run is provided to complete the Plack::Handler interface and allow the server to be executed with the provided psgi app

PROTECTED_METHODS

    after _start



    is Event



_start is advised to supply the proper input (HTTP::Parser) and output (Stream) filters.

    write



    (PSGIServerContext $c, Str $data)



write will alter the data if necessary for a chunked transfer encoded response and send it to the output buffer for the current context

    close



    (PSGIServerContext $c)



close will close the connection for the current context, but flushing the output buffer first

    handle_socket_error



    (Str $action, Int $code, Str $message, WheelID $id) is Event



handle_socket_error overridden from POEx::Role::TCPServer to delete the wheel when a socket level error happens. If more intelligent actions are required, please feel free to exclude this method and provide your own implementation

    handle_listen_error



    (Str $action, Int $code, Str $message, WheelID $id) is Event



handle_listen_error is overridden from POEx::Role::TCPServer to die when the SocketFactory fails to listen to the provided address/port. If more intelligent actions are required, please feel free to exclude this method and provide your own implementation

    process_headers



    (PSGIServerContext $c, PSGIResponse $response)



process_headers takes the headers from the PSGIResponse, and sends it to the output buffer for the current context. This method also determines if the response body should be transfer encoded as chunked based on the Connection and Content-Length headers.

    http_preamble



    (PSGIServerContext $c, PSGIResponse $response)



http_preamble sends the first line of the HTTP response to the output buffer of the current context

    http_body_allowed



    (PSGIServerContext $c, PSGIResponse $response) returns (Bool)



http_body_allowed checks the result code from the PSGIResponse to determine if a body should be allowed to be returned. Returns true if a body is allowed, false otherwise.

    respond



    (PSGIServerContext $c, PSGIResponse $response) is Event



respond processes the PSGIResponse to write out a valid HTTP response. If the body of the response is a real filehandle, it will be streamed appropriately via POEx::Role::PSGIServer::Streamer. If not, it will be iterated with which ever appropriate interface to the output buffer. If no body is provided, generate_push_writer is called to generate an appropriate object for use in push responses.

    generate_push_writer



    (PSGIServerContext $c) returns (Object)



generate_push_writer by default constructs and returns a POEx::Role::PSGIServer::ProxyWriter object that implements the push-object interface defined in PSGI

    generate_psgi_env



    (PSGIServerContext $c) returns (HashRef)



generate_psgi_env returns a suitable HashRef as defined by PSGI for application use. If additional application specific items need to be added to the hash, please feel free to advise this method

    build_server_context



    (HTTPRequest $req, WheelID $wheel_id) returns (PSGIServerContext)



build_server_context constructs and returns a PSGIServerContext in POEx::Types::PSGIServer for the current connection

    handle_inbound_data



    (HTTPRequest $req, WheelID $wheel_id) is Event



handle_inbound_data implements the required method for POEx::Role::TCPServer. It builds a server context, generates a psgi env hash, runs the psgi app, and then responds to the client

PRIVATE_METHODS

    _write



    (PSGIServerContext $c, Str $data)



_write accesses the proper wheel for this context and puts the supplied data into the output buffer

AUTHOR

Nicholas Perez <nperez@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Infinity Interactive.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 POEX::ROLE::PSGISERVER (3) 2011-03-08

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.