Branch Coverage

blib/lib/Perlbal/ClientProxy.pm
Criterion Covered Total %
branch 173 290 59.6


line true false branch
65 25 0 unless ref $self
123 0 0 $svc_name ? :
124 0 0 unless ($svc)
148 0 17 unless $$self{'primary_res_hdrs'} ||= $primary_res_hdrs
151 15 2 if (defined $urls)
156 0 17 unless $uri =~ m[^http://(.+?)(?::(\d+))?(/.*)?$]
163 0 17 if ($$self{'currently_reproxying'})
169 0 17 unless $$self{'reproxy_uris'}
170 0 17 unless @{[] unless $$self{'reproxy_uris'};}
173 0 17 if ($primary_res_hdrs and my $expected_size = $primary_res_hdrs->header('X-REPROXY-EXPECTED-SIZE'))
186 1 1 if ($$self{'currently_reproxying'}) { }
203 0 129 unless my $backend = $$self{'backend'}
213 129 0 defined $$backend{'service'} ? :
228 0 16 unless (defined $datref)
239 0 16 if (my $range = $$self{'req_headers'}->header('Range'))
242 0 16 if (my $host = $$self{'req_headers'}->header('Host'))
246 1 15 $$self{'req_headers'}->request_method eq 'HEAD' ? :
268 15 1 if $code >= 200 and $code <= 299
269 0 1 if $code == 416
274 15 0 unless defined $$self{'reproxy_expected_size'}
278 1 15 if (&$bad_code() or &$bad_size())
286 0 15 if $$self{'service'}->run_hook('reproxy_response_received', $be)
304 0 6 if $$self{'service'}->run_hook('start_file_reproxy', $self, \$file)
307 0 6 if (my $expected_size = $hd->header('X-REPROXY-EXPECTED-SIZE'))
317 0 6 if $$self{'closed'}
321 0 6 unless ($size)
325 0 6 if (defined $$self{'reproxy_expected_size'} and $$self{'reproxy_expected_size'} != $size)
332 6 0 if (-f _)
339 0 6 if ($status == 416)
341 0 0 $size ? :
346 0 6 if $hd->response_code == 204
350 6 0 if ($status == 200) { }
0 0 elsif ($status == 206) { }
368 0 6 if ($$self{'req_headers'}->request_method eq 'HEAD' or $not_satisfiable)
378 0 6 if ($$self{'closed'})
379 0 0 if $fh
384 0 6 unless ($fh)
390 0 6 if ($status == 206)
405 127 152 unless @_
408 17 135 unless $backend
420 28 107 if ($$self{'unread_data_waiting'})
425 106 29 unless $$self{'bureason'}
450 130 0 unless $$self{'unread_data_waiting'}
470 21 121 unless $self->SUPER::http_response_sent
474 0 121 if (my $be = $$self{'backend'})
513 0 135 if $$self{'backend_requested'}
533 1 25 if $$self{'closed'}
539 1 24 if (my $backend = $$self{'backend'}) { }
542 1 0 $reason ? :
556 0 142 $not_done_reading ? :
569 1 0 if $$self{'bureason'}
586 0 6 if ($$self{'backend_stalled'} and my $backend = $$self{'backend'})
603 100 141 unless ($$self{'req_headers'})
605 88 12 if $self->read_request_headers
611 4 137 unless ($$self{'is_buffering'} or $$self{'read_ahead'} < 32768)
619 8 129 if (my $cus = $$self{'chunked_upload_state'})
624 0 8 if ($$self{'read_ahead'} > 1048576)
638 89 40 if $remain and $remain < $read_size
645 1 128 unless defined $bref
650 1 127 unless ($remain)
664 0 127 unless $len
667 127 0 if $remain
674 0 127 if (my $session = $$self{'upload_session'})
678 0 0 if ($cl and $remain and ($$self{'last_upload_packet'} || 0) != $now)
684 0 0 if ($udp_sock)
698 0 127 if ($$self{'responded'})
702 0 0 if $done_reading
715 84 43 if ($done_reading)
716 0 84 if $$self{'content_length_remain'} < 0
724 39 88 if ($backend)
740 47 41 if $$self{'bureason'}
745 6 35 if not $done_reading and $$self{'read_ahead'} < $$self{'service'}{'buffer_backend_connect'}
749 2 33 if $$self{'service'}{'buffer_uploads'} and $self->decide_to_buffer_to_disk
754 0 33 if $svc->run_hook('proxy_read_request', $self)
766 0 143 unless ($req_hd)
775 0 143 if $svc->run_hook('start_proxy_request', $self)
776 0 143 if $svc->run_hook('start_http_request', $self)
778 2 141 if ($self->handle_chunked_upload) { }
788 1 140 if (defined $length and $length < 0)
794 85 55 if $$self{'content_length_remain'}
799 0 142 if $$svc{'upload_status_listeners'} and $self->handle_upload_tracking
807 2 140 if ($$self{'chunked_upload_state'}) { }
61 79 elsif ($$self{'content_length_remain'} and $$self{'service'}{'buffer_backend_connect'}) { }
820 6 73 if $$svc{'reproxy_cache'} and $self->satisfy_request_from_cache
830 141 2 unless $te and $te eq 'chunked'
831 0 2 unless $$self{'service'}{'buffer_uploads'}
836 1 1 if ($eh and $eh =~ /\b100-continue\b/)
852 0 12 if ($max_size and $$self{'request_body_length'} > $max_size)
884 23 7 unless my $reproxy = $cache->get($key)
888 1 6 if time > $timeout
891 18 6 ref $_ eq 'SCALAR' ? :
0 6 unless $headers
893 4 2 if (my $ims = $req_hd->header('If-Modified-Since'))
901 4 0 if ($ims eq $lm)
929 0 0 unless $req_hd->request_uri =~ /[\?&]client_up_sess=(\w{5,50})\b/
935 0 0 if ($req_hd->request_uri =~ m[^/__upload_status\?])
938 0 0 $status ? :
970 27 34 if ($$self{'service'}{'buffer_uploads'} and $$self{'service'}{'buffer_upload_threshold_size'})
972 26 1 if ($req_hd->content_length >= $$self{'service'}{'buffer_upload_threshold_size'})
974 2 24 if ($ENV{'PERLBAL_DEBUG_BUFFERED_UPLOADS'})
987 6 29 if $$self{'service'}{'buffer_uploads'}
996 0 6 unless $$self{'is_buffering'}
997 0 6 if defined $$self{'bureason'}
1009 1 5 if ($$self{'service'}{'buffer_upload_threshold_rate'} > 0 and $rate < $$self{'service'}{'buffer_upload_threshold_rate'})
1016 1 5 if ($$self{'service'}{'buffer_upload_threshold_time'} > 0 and $etime > $$self{'service'}{'buffer_upload_threshold_time'})
1022 4 2 unless ($reason)
1032 2 0 if ($ENV{'PERLBAL_DEBUG_BUFFERED_UPLOADS'})
1044 0 29 if $$self{'is_writing'}
1047 2 27 if ($$self{'chunked_upload_state'})
1052 0 29 if ($clen != $$self{'buoutpos'})
1059 28 1 if $$self{'bufh'}
1068 0 38 unless $self and $be
1073 37 1 if ($$self{'buoutpos'} < $clen)
1075 0 37 if ($sent < 0)
1076 0 0 if $! == 32
1077 0 0 if $! == 104
1085 29 9 if ($$self{'buoutpos'} >= $clen)
1098 0 152 if $$self{'read_ahead'} >= 1048576
1099 0 152 if $$self{'is_writing'}
1100 62 90 unless $$self{'is_buffering'} and $$self{'read_ahead'}
1103 29 61 unless ($$self{'bufilename'})
1115 0 29 unless ($$self{'bufh'})
1133 0 61 unless ($$self{'bufh'})
1145 34 27 if $$self{'content_length_remain'} or $$self{'chunked_upload_state'}
1155 0 61 unless ($bytes > 0)
1166 0 61 if ($bytes < $len)
1173 12 49 if ($$self{'chunked_upload_state'}) { }
27 22 elsif ($$self{'read_ahead'} <= 0 and $$self{'content_length_remain'} <= 0) { }
1175 0 12 if ($$self{'unread_data_waiting'} and $$self{'read_ahead'} < 1048576)
1180 0 12 if ($$self{'read_ahead'} == 0 and $$self{'chunked_upload_state'}->hit_zero_chunk)
1203 1 29 unless $$self{'bufh'}
1213 0 29 if ($@)
1220 0 0 if ($_[0] != 0 and $!)
1227 0 29 if ($@)
1236 0 0 unless $$svc{'enable_error_retries'}
1238 0 0 if ++$$self{'retry_count'} > @sched
1250 0 0 if ($delay) { }
1252 0 0 if $$self{'closed'}
1265 0 0 if ($$self{'backend'}) { }
1269 0 0 if $$self{'write_buf_size'} > 0
1272 0 0 if $$self{'high_priority'}
1273 0 0 if $$self{'low_priority'}
1274 0 0 if $$self{'responded'}
1275 0 0 if defined $$self{'content_length_remain'}
1277 0 0 if $$self{'currently_reproxying'}