… | |
… | |
139 | package conn; |
139 | package conn; |
140 | |
140 | |
141 | use Socket; |
141 | use Socket; |
142 | use HTTP::Date; |
142 | use HTTP::Date; |
143 | use Convert::Scalar 'weaken'; |
143 | use Convert::Scalar 'weaken'; |
144 | use Linux::AIO; |
144 | use IO::AIO; |
145 | |
145 | |
146 | Linux::AIO::min_parallel $::AIO_PARALLEL; |
146 | IO::AIO::min_parallel $::AIO_PARALLEL; |
147 | |
147 | |
148 | Event->io(fd => Linux::AIO::poll_fileno, |
148 | Event->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 | |
152 | our %conn; # $conn{ip}{self} => connobj |
152 | our %conn; # $conn{ip}{self} => connobj |
153 | our %uri; # $uri{ip}{uri}{self} |
153 | our %uri; # $uri{ip}{uri}{self} |
154 | our %blocked; |
154 | our %blocked; |
155 | our %mimetype; |
155 | our %mimetype; |
… | |
… | |
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 | |
541 | sub handle_file { |
541 | sub 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 | |