ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/httpd.pl
(Generate patch)

Comparing Coro/myhttpd/httpd.pl (file contents):
Revision 1.73 by root, Sat Oct 5 09:02:17 2002 UTC vs.
Revision 1.77 by root, Sat Sep 17 20:21:11 2005 UTC

139package conn; 139package conn;
140 140
141use Socket; 141use Socket;
142use HTTP::Date; 142use HTTP::Date;
143use Convert::Scalar 'weaken'; 143use Convert::Scalar 'weaken';
144use Linux::AIO; 144use IO::AIO;
145 145
146Linux::AIO::min_parallel $::AIO_PARALLEL; 146IO::AIO::min_parallel $::AIO_PARALLEL;
147 147
148Event->io(fd => Linux::AIO::poll_fileno, 148Event->io(fd => IO::AIO::poll_fileno,
149 poll => 'r', async => 1, 149 poll => 'r', async => 1,
150 cb => \&Linux::AIO::poll_cb); 150 cb => \&IO::AIO::poll_cb);
151 151
152our %conn; # $conn{ip}{self} => connobj 152our %conn; # $conn{ip}{self} => connobj
153our %uri; # $uri{ip}{uri}{self} 153our %uri; # $uri{ip}{uri}{self}
154our %blocked; 154our %blocked;
155our %mimetype; 155our %mimetype;
212sub prune_caches { 212sub prune_caches {
213 prune_cache \%conn; 213 prune_cache \%conn;
214 prune_cache \%uri; 214 prune_cache \%uri;
215 215
216 for (keys %blocked) { 216 for (keys %blocked) {
217 delete $blocked{$_} if $blocked{$_}[0] > $::NOW; 217 delete $blocked{$_} unless $blocked{$_}[0] > $::NOW;
218 } 218 }
219} 219}
220 220
221Event->timer(interval => 60, cb => \&prune_caches); 221Event->timer(interval => 60, cb => \&prune_caches);
222 222
529 my $self = shift; 529 my $self = shift;
530 my $idx = $self->diridx; 530 my $idx = $self->diridx;
531 531
532 $self->response(200, "ok", 532 $self->response(200, "ok",
533 { 533 {
534 "Content-Type" => "text/html", 534 "Content-Type" => "text/html; charset=utf-8",
535 "Content-Length" => length $idx, 535 "Content-Length" => length $idx,
536 "Last-Modified" => time2str ($self->{stat}[9]), 536 "Last-Modified" => time2str ($self->{stat}[9]),
537 }, 537 },
538 $idx); 538 $idx);
539} 539}
540 540
541sub handle_file { 541sub handle_file {
542 my ($self, $queue, $tbf) = @_; 542 my ($self, $queue, $tbf) = @_;
543 my $length = $self->{stat}[7]; 543 my $length = $self->{stat}[7];
544 my $hdr = { 544 my $hdr = {
545 "Last-Modified" => time2str ((stat _)[9]), 545 "Last-Modified" => time2str ((stat _)[9]),
546 "Accept-Ranges" => "bytes",
546 }; 547 };
547 548
548 my @code = (200, "ok"); 549 my @code = (200, "ok");
549 my ($l, $h); 550 my ($l, $h);
550 551

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines