38 |
|
|
39 |
use html; |
use html; |
40 |
our $static_pids; |
our $static_pids; |
41 |
|
use progress_bar; |
42 |
|
|
43 |
sub static { |
sub static { |
44 |
my ($client,$path) = @_; |
my ($client,$path) = @_; |
62 |
|
|
63 |
my $size = -s $full || return; |
my $size = -s $full || return; |
64 |
|
|
|
$client->autoflush(1); |
|
|
|
|
65 |
print $client "HTTP/1.0 200 OK\r\nContent-Type: $type\r\nContent-Length: $size\r\nConnection: close\r\n\r\n"; |
print $client "HTTP/1.0 200 OK\r\nContent-Type: $type\r\nContent-Length: $size\r\nConnection: close\r\n\r\n"; |
66 |
|
|
67 |
open(my $fh, $full); |
open(my $fh, $full); |
70 |
my $buff; |
my $buff; |
71 |
my $pos = 0; |
my $pos = 0; |
72 |
|
|
73 |
print "static $path $type $size block: $block\n"; |
warn "static $path $type $size block: $block\n"; |
74 |
|
|
75 |
|
progress_bar::start; |
76 |
|
|
77 |
while( my $len = read $fh, $buff, $block ) { |
while( my $len = read $fh, $buff, $block ) { |
78 |
print $client $buff; |
print $client $buff; |
79 |
|
$client->flush; |
80 |
$pos += $len; |
$pos += $len; |
81 |
printf "%s %d/%d %.2f%%\r", $path, $pos, $size, $pos * 100 / $size; |
progress_bar::tick( $path, $pos, $size ); |
82 |
} |
} |
83 |
close($fh); |
close($fh); |
84 |
close($client); |
close($client); |
85 |
|
|
86 |
print "\n"; |
print STDERR "\n"; |
87 |
|
|
88 |
|
warn "exit static child"; |
89 |
|
|
90 |
exit; |
exit(0); |
91 |
} |
} |
92 |
|
|
93 |
use boolean; |
use boolean; |