… | |
… | |
555 | }; |
555 | }; |
556 | |
556 | |
557 | my @code = (200, "ok"); |
557 | my @code = (200, "ok"); |
558 | my ($l, $h); |
558 | my ($l, $h); |
559 | |
559 | |
560 | if ($self->{h}{range} =~ /^bytes=(.*)$/) { |
560 | if ($self->{h}{range} =~ /^bytes=(.*)$/i) { |
561 | for (split /,/, $1) { |
561 | for (split /,/, $1) { |
562 | if (/^-(\d+)$/) { |
562 | if (/^-(\d+)$/) { |
563 | ($l, $h) = ($length - $1, $length - 1); |
563 | ($l, $h) = ($length - $1, $length - 1); |
564 | } elsif (/^(\d+)-(\d*)$/) { |
564 | } elsif (/^(\d+)-(\d*)$/) { |
565 | ($l, $h) = ($1, ($2 ne "" || $2 >= $length) ? $2 : $length - 1); |
565 | ($l, $h) = ($1, ($2 ne "" || $2 >= $length) ? $2 : $length - 1); |
… | |
… | |
631 | |
631 | |
632 | Coro::AIO::aio_read $fh, $l, ($h > $bufsize ? $bufsize : $h), my $buf, 0 |
632 | Coro::AIO::aio_read $fh, $l, ($h > $bufsize ? $bufsize : $h), my $buf, 0 |
633 | or last; |
633 | or last; |
634 | |
634 | |
635 | $tbf->request (length $buf); |
635 | $tbf->request (length $buf); |
636 | my $w = syswrite $self->{fh}, $buf |
636 | my $w = $self->{fh}->syswrite ($buf) |
637 | or last; |
637 | or last; |
638 | $::written += $w; |
638 | $::written += $w; |
639 | $self->{written} += $w; |
639 | $self->{written} += $w; |
640 | $l += $w; |
640 | $l += $w; |
641 | } |
641 | } |