blib/lib/Net/DirectConnect/http.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
condition | 0 | 24 | 0.0 |
line | !l | l&&!r | l&&r | condition |
---|---|---|---|---|
75 | 0 | 0 | 0 | $$self{'http_control'} and $$self{'http_geturl'} eq '/' |
0 | 0 | 0 | $$self{'http_download'} and my $full = $$self{'share_full'}{$$self{'http_getfile'}} | |
0 | 0 | 0 | $$self{'http_control'} and $$self{'http_geturl'} =~ m[^/dl/(.+)$] |
line | l | !l | condition |
---|---|---|---|
54 | 0 | 0 | $$self{'handler_int'}{'unknown'} ||= sub { my $self = shift() if ref $_[0]; ($$self{'http_headers'}{$_[0]} = $_[1]) =~ s/^: |\s+$//g; } |
103 | 0 | 0 | {'xml', 'text/xml'}->{lc(($name =~ /\.(\w+)/)[0])} || 'binary/octet-stream' |
125 | 0 | 0 | $$self{'parse'} ||= {'DELLLLLLLnoGET', sub {
my $self = shift() if ref $_[0];
my($url, $prot) = split(/\s/, $_[0], 3);
$self->log('dev', "get $url : $prot");
$$self{'http_geturl'} = $url;
}
, "\r", sub {
my $self = shift() if ref $_[0];
($$self{'http_geturl'}) = split(' ', $$self{'http_headers'}{'GET'}, 2);
($$self{'http_getfile'}) = $$self{'http_geturl'} =~ m[^/(.+)];
my $c = "HTTP/1.1 200 OK\nContent-Type: text/html; charset=utf-8\n\n";
if ($$self{'http_control'} and $$self{'http_geturl'} eq '/') {
$c .= 'clients: ' . join(', ', map({"$_($$self{'clients'}{$_}{'status'}" . (!$$self{'clients'}{$_}{'filebytes'} ? () : ":$$self{'clients'}{$_}{'filebytes'}/$$self{'clients'}{$_}{'filetotal'}") . ')';} sort(keys %{$$self{'clients'};}))) . ' peers: ' . join(' ', map({join ' ', $$_{'INF'}{'NI'}, $$_{'INF'}{'SS'}, $$_{'INF'}{'I4'};} (sort {$$b{'INF'}{'SS'} <=> $$a{'INF'}{'SS'};} values %{$$self{'peers_cid'};}))) . ' ' . ''; } elsif ($$self{'http_download'} and my $full = $$self{'share_full'}{$$self{'http_getfile'}}) { my($name) = $full =~ m[([^/]+)$]; my $size = -s $full; my $sizep = $size + 1; my($from, $to) = $$self{'http_headers'}{'Range'} =~ /^bytes=(\d+)\-(\d*)/; $to ||= $size if $from; my $type = {'xml', 'text/xml'}->{lc(($name =~ /\.(\w+)/)[0])} || 'binary/octet-stream'; $c = 'HTTP/1.1 ' . ($from ? '206 Partial Content' : '200 OK') . "\nContent-Type: $type" . "\nContent-Length: $size" . "\nAccept-Ranges: bytes\n" . (!$from ? () : "Content-Range: bytes $from-$to/$sizep\n") . "Content-Disposition: attachment; filename=$name\n\n"; $self->send(&Encode::encode('utf8', $c, &Encode::FB_WARN())); $self->file_send($$self{'share_full'}{$$self{'http_getfile'}}, $from, $to); return; } elsif ($$self{'http_control'} and $$self{'http_geturl'} =~ m[^/dl/(.+)$]) { $$self{'parent'}{'parent'}->download($1); $c .= "try dl [$1]"; }; $self->send(&Encode::encode('utf8', $c, &Encode::FB_WARN())); $self->destroy; } } |
line | l | !l&&r | !l&&!r | condition |
---|---|---|---|---|
39 | 0 | 0 | 0 | $$self{$_} //= $_{$_} |
44 | 0 | 0 | 0 | $$self{$_} ||= $$self{'parent'}{$_} |
102 | 0 | 0 | 0 | $to ||= $size |