… | |
… | |
55 | our $httpevent = new Coro::Signal; |
55 | our $httpevent = new Coro::Signal; |
56 | |
56 | |
57 | our $queue_file = new transferqueue $MAX_TRANSFERS; |
57 | our $queue_file = new transferqueue $MAX_TRANSFERS; |
58 | our $queue_index = new transferqueue 10; |
58 | our $queue_index = new transferqueue 10; |
59 | |
59 | |
60 | our $tbf_top = new tbf rate => 200000; |
60 | our $tbf_top = new tbf rate => 100000; |
61 | |
61 | |
62 | my $unused_bytes = 0; |
62 | my $unused_bytes = 0; |
63 | my $unused_last = time; |
63 | my $unused_last = time; |
64 | |
64 | |
65 | sub unused_bandwidth { |
65 | sub unused_bandwidth { |
… | |
… | |
232 | $hdr->{"Content-Length"} = length $content; |
232 | $hdr->{"Content-Length"} = length $content; |
233 | $GZ = sprintf "GZ%02d", 100 - 100*((length $content) / $orig); |
233 | $GZ = sprintf "GZ%02d", 100 - 100*((length $content) / $orig); |
234 | } |
234 | } |
235 | |
235 | |
236 | $res .= "Date: $HTTP_NOW\015\012"; |
236 | $res .= "Date: $HTTP_NOW\015\012"; |
|
|
237 | $res .= "Server: $::NAME\015\012"; |
237 | |
238 | |
238 | while (my ($h, $v) = each %$hdr) { |
239 | while (my ($h, $v) = each %$hdr) { |
239 | $res .= "$h: $v\015\012" |
240 | $res .= "$h: $v\015\012" |
240 | } |
241 | } |
241 | $res .= "\015\012"; |
242 | $res .= "\015\012"; |
… | |
… | |
568 | |
569 | |
569 | $self->response(@code, $hdr, ""); |
570 | $self->response(@code, $hdr, ""); |
570 | |
571 | |
571 | if ($self->{method} eq "GET") { |
572 | if ($self->{method} eq "GET") { |
572 | $self->{time} = $::NOW; |
573 | $self->{time} = $::NOW; |
|
|
574 | $self->{written} = 0; |
573 | |
575 | |
574 | my $current = $Coro::current; |
576 | my $current = $Coro::current; |
575 | |
577 | |
576 | my ($fh, $buf, $r); |
578 | my ($fh, $buf, $r); |
577 | |
579 | |
… | |
… | |
593 | while ($h > 0) { |
595 | while ($h > 0) { |
594 | unless ($locked) { |
596 | unless ($locked) { |
595 | if ($locked ||= $transfer->try($::WAIT_INTERVAL)) { |
597 | if ($locked ||= $transfer->try($::WAIT_INTERVAL)) { |
596 | $bufsize = $::BUFSIZE; |
598 | $bufsize = $::BUFSIZE; |
597 | $self->{time} = $::NOW; |
599 | $self->{time} = $::NOW; |
|
|
600 | $self->{written} = 0; |
598 | } |
601 | } |
599 | } |
602 | } |
600 | |
603 | |
601 | if ($blocked{$self->{remote_id}}) { |
604 | if ($blocked{$self->{remote_id}}) { |
602 | $self->{h}{connection} = "close"; |
605 | $self->{h}{connection} = "close"; |