Net-Async-HTTP-Server

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

             $response->content_type( "text/plain" );
             $response->content_length( length $response->content );
    
             $req->respond( $response );
          },
       );
    
       $loop->add( $httpserver );
    
       $httpserver->listen(
          addr => { family => "inet6", socktype => "stream", port => 8080 },
       )->get
    
       $loop->run;

DESCRIPTION

    This module allows a program to respond asynchronously to HTTP
    requests, as part of a program based on IO::Async. An object in this
    class listens on a single port and invokes the on_request callback or
    subclass method whenever an HTTP request is received, allowing the

examples/hello-world.pl  view on Meta::CPAN

      $response->content_length( length $response->content );

      $req->respond( $response );
   },
);

$loop->add( $httpserver );

$httpserver->listen(
   addr => {
      family   => "inet6",
      socktype => "stream",
      port     => $SSL ? 8443 : 8080,
   },
   on_listen_error => sub { die "Cannot listen - $_[-1]\n" },
   ( $SSL ? (
      extensions    => [ 'SSL' ],
      SSL_key_file  => "t/privkey.pem",
      SSL_cert_file => "t/server.pem", )
      : () ),
);

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

         $response->content_type( "text/plain" );
         $response->content_length( length $response->content );

         $req->respond( $response );
      },
   );

   $loop->add( $httpserver );

   $httpserver->listen(
      addr => { family => "inet6", socktype => "stream", port => 8080 },
   )->get

   $loop->run;

=head1 DESCRIPTION

This module allows a program to respond asynchronously to HTTP requests, as
part of a program based on L<IO::Async>. An object in this class listens on a
single port and invokes the C<on_request> callback or subclass method whenever
an HTTP request is received, allowing the program to respond to it.

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

            200,
            [ "Content-Type" => "text/plain" ],
            [ "Hello, world!" ],
         ];
      },
   );

   $loop->add( $httpserver );

   $httpserver->listen(
      addr => { family => "inet6", socktype => "stream", port => 8080 },
   )->get;

   $loop->run;

=head1 DESCRIPTION

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



( run in 0.487 second using v1.01-cache-2.11-cpan-4face438c0f )