Net-Async-HTTP-Server

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.04    CHANGES:
         * Provide access to all the HTTP headers via ->headers method
         * Set HTTP headers in PSGI environment
         * Remember not to write content using chunked transfer encoding when
           that mode isn't actually set

0.03    CHANGES:
         * Implement PSGI container subclass and Plack::Handler:: module
         * Added more accessors for request fields
         * Reworked chunked response streaming API
         * Don't force a Content-Length header in normal operation

0.02    CHANGES:
         * Changed request/response API - new NaHTTP::Server::Request objects
         * Added response streaming with HTTP/1.1 chunked encoding

0.01    First version, released on an unsuspecting world.

MANIFEST  view on Meta::CPAN

psgifiles/helloworld.psgi
psgifiles/sleepy.psgi
t/00use.t
t/01respond.t
t/02respond-chunked.t
t/03respond-code.t
t/04close.t
t/05refcount.t
t/10request-HTTP.t
t/20psgi.t
t/21psgi-streaming.t
t/22psgi-dup-headers.t
t/70metrics.t
t/80cross-http.t
t/81cross-https.t
t/99pod.t
t/privkey.pem
t/regen-certs.sh
t/server.pem
README
LICENSE

README  view on Meta::CPAN


    Invoked by the protocol stream handler to create a new request object
    representing an incoming request. This is provided as a method for
    subclasses to overload, if they wish to represent requests with
    subclasses of the basic request representation.

TODO

      * Don't use HTTP::Message objects as underlying implementation

      * Consider how to do streaming request inbound

      * Lots more testing

AUTHOR

    Paul Evans <leonerd@leonerd.org.uk>

lib/Net/Async/HTTP/Server.pm  view on Meta::CPAN

=head1 TODO

=over 2

=item *

Don't use L<HTTP::Message> objects as underlying implementation

=item *

Consider how to do streaming request inbound

=item *

Lots more testing

=back

=cut

=head1 AUTHOR

lib/Net/Async/HTTP/Server/PSGI.pm  view on Meta::CPAN

This subclass of L<Net::Async::HTTP::Server> allows an HTTP server to use a
L<PSGI> application to respond to requests. It acts as a gateway between the
HTTP connection from the web client, and the C<PSGI> application. Aside from
the use of C<PSGI> instead of the C<on_request> event, this class behaves
similarly to C<Net::Async::HTTP::Server>.

To handle the content length when sending responses, the PSGI implementation
may add a header to the response. When sending a plain C<ARRAY> of strings, if
a C<Content-Length> header is absent, the length will be calculated by taking
the total of all the strings in the array, and setting the length header. When
sending content from an IO reference or using the streaming responder C<CODE>
reference, the C<Transfer-Encoding> header will be set to C<chunked>, and all
writes will be performed as C<HTTP/1.1> chunks.

=cut

=head1 PARAMETERS

The following named parameters may be passed to C<new> or C<configure>:

=over 8

lib/Net/Async/HTTP/Server/PSGI.pm  view on Meta::CPAN

      REQUEST_METHOD      => $req->method,
      REQUEST_URI         => $req->path,
      'psgi.version'      => [1,0],
      'psgi.url_scheme'   => "http",
      'psgi.input'        => $stdin,
      'psgi.errors'       => \*STDERR,
      'psgi.multithread'  => 0,
      'psgi.multiprocess' => 0,
      'psgi.run_once'     => 0,
      'psgi.nonblocking'  => 1,
      'psgi.streaming'    => 1,

      # Extensions
      'psgix.io'                  => $socket,
      'psgix.input.buffered'      => 1, # we're using a PerlIO scalar handle
      'net.async.http.server'     => $self,
      'net.async.http.server.req' => $req,
      'io.async.loop'             => $self->get_loop,
   );

   if( $socket->can( "sockport" ) ) { # INET or IP

t/20psgi.t  view on Meta::CPAN

         SERVER_PORT     => $server->read_handle->sockport,
         SERVER_PROTOCOL => "HTTP/1.1",

         HTTP_USER_AGENT => "unittest",

         'psgi.version'      => [1,0],
         'psgi.url_scheme'   => "http",
         'psgi.run_once'     => 0,
         'psgi.multiprocess' => 0,
         'psgi.multithread'  => 0,
         'psgi.streaming'    => 1,
         'psgi.nonblocking'  => 1,

         'psgix.input.buffered' => 1,
      },
      'received $env in PSGI app'
   );

   my $expect = join( "", map "$_$CRLF",
         "HTTP/1.1 200 OK",
         "Content-Length: 12",



( run in 0.272 second using v1.01-cache-2.11-cpan-4d50c553e7e )