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
POEx::Role::PSGIServer(3) User Contributed Perl Documentation POEx::Role::PSGIServer(3)

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

version 1.110670

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

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

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.

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.

    (ClassName $class: @args)

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

    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

    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)

    (CodeRef $app)

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

    is Event

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

    (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

    (PSGIServerContext $c)

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

    (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

    (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

    (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.

    (PSGIServerContext $c, PSGIResponse $response)

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

    (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.

    (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.

    (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

    (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

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

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

    (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

    (PSGIServerContext $c, Str $data)

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

Nicholas Perez <nperez@cpan.org>

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.

2011-03-08 perl v5.32.1

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

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