HTTP-Server-Singlethreaded

 view release on metacpan or  search on metacpan

Singlethreaded.pm  view on Meta::CPAN

   	   HandleDRV( &{$continue[$fn]} );
           length ($outbuf[$fn]) or push @PollMe, $fn;
           next;
         };
        }
      }else{
         warn "Error writing to socket $OutFileHandle ($fn): $!";
         $outbuf[$fn] = '';
      }

      # rewrite this when adding keepalive support
      length($outbuf[$fn]) or close $OutFileHandle;
   }

   # read incoming data to inbufs and list inbufs with complete requests
   # close bad connections
   for(@Clients){
      defined($fn = fileno($_)) or next;
      if(vec($rout,$fn,1)){

         my $char;

Singlethreaded.pm  view on Meta::CPAN

     function => { # must be a hash ref
                    '/time/' => sub {
                       "Content-type: text/plain\n\n".localtime
                    }
     },
     path => \%ChangeConfigurationWhileServingBySettingThis;
  #
  # "top level select loop" is invoked explicitly
  for(;;){
    #
    # manage keepalives on database handles
    if ((time - $lasttime) > 40){
       ...
       $lasttime = time;
    };
    # Auto restart on editing this file
    BEGIN{$OriginalM = -M $0}
    exec "perl -w $0" if -M $0 != $OriginalM;
    #
    # do pending IO, invoke functions, read statics
    # HTTP::Server::Singlethreaded::Serve()

Singlethreaded.pm  view on Meta::CPAN


=head2 $Timeout

the timeout for the select.  C<0> will cause C<Serve> to simply poll.
C<undef>, to cause Serve to block until thereis a connection, can only
be passed on the C<use> line.

=head2 $MaxClients

if we have more active clients than this we won't accept more. Since
we're not respecting keepalive at this time, this number indicates
how long of a backlog singlethreaded will maintain at any moment,and
should be orders of magnitude lower than the number of simultaneous
web page viewers possible. Depending on how long your functions take.

=head2 $WebEmail

an e-mail address for whoever is responsible for this server,
for use in error messages.

=head2 $forkwidth  ( commented out by default )

Singlethreaded.pm  view on Meta::CPAN

break any installed code that used the "poll" feature or returned the continue
coderef in a hashref or arrayref as previously allowed.

There was a serious problem preventing continuation systems from working right,
so I doubt anyone was using those features.

=item 0.12  July, 2009

silenced a warning about C<$_{Data}> being uninitialized

instead of actually implementing keep-alive, added a "Connection: close" header
line at the beginning of each response

=back

=head1 EXPORTS

C<Serve()> is exported, and must be called in a loop.

=head1 AUTHOR



( run in 1.855 second using v1.01-cache-2.11-cpan-71847e10f99 )