Branch Coverage

blib/lib/Hypersonic.pm
Criterion Covered Total %
branch 207 414 50.0


line true false branch
35 0 42 if ($opts{'tls'})
36 0 0 unless $HAS_TLS
37 0 0 unless $opts{'cert_file'}
38 0 0 unless $opts{'key_file'}
39 0 0 unless -f $opts{'cert_file'}
40 0 0 unless -f $opts{'key_file'}
44 0 42 if ($opts{'http2'})
45 0 0 unless $opts{'tls'}
46 0 0 unless $HAS_HTTP2
100 0 42 $opts{'tls'} ? :
141 0 4 unless $path =~ m[^/]
142 0 4 unless ref $handler eq "CODE"
165 2 3 if ($path =~ /$pattern/)
171 1 0 if defined $captures[$i]
195 0 0 unless $url_prefix =~ m[^/]
196 0 0 unless -d $directory
275 0 0 unless ref $handler eq "CODE" or $is_builder
284 0 0 unless ref $handler eq "CODE" or $is_builder
360 0 0 unless (Hypersonic::Compress::check_zlib())
378 1 48 unless $path =~ m[^/]
379 1 47 unless ref $handler eq "CODE"
394 13 34 if (ref $opts eq "HASH")
395 6 7 $opts->{'dynamic'} ? :
398 9 0 $opts->{$feat} ? :
9 95 if exists $opts->{$feat}
408 5 53 if ($segments[$i] =~ /^:(\w+)$/)
415 7 40 if ($features{'streaming'})
420 0 47 if ($features{'need_xs_builder'})
445 1 16 unless @{$self->{'routes'};} or @{$self->{'static_dirs'} // [];}
446 1 15 if $self->{'compiled'}
451 0 15 if (my $static_dirs = $self->{'static_dirs'})
487 6 24 if ($route->{'dynamic'}) { }
490 3 3 if ($route->{'method'} =~ /^(POST|PUT|PATCH)$/)
499 0 6 if $f->{'parse_query'}
500 0 6 if $f->{'parse_headers'}
501 0 6 if $f->{'parse_cookies'}
502 1 5 if $f->{'parse_json'}
503 0 6 if $f->{'parse_form'}
504 0 6 if $f->{'response_helpers'}
505 2 4 if $f->{'streaming'}
506 0 6 if $f->{'need_xs_builder'}
510 6 0 if ($handler_code)
512 0 6 if $handler_code =~ /\{['"]*query['"]*\}/
513 0 6 if $handler_code =~ /\{['"]*headers['"]*\}/
514 0 6 if $handler_code =~ /\{['"]*cookies['"]*\}/
515 0 6 if $handler_code =~ /\{['"]*json['"]*\}/
516 0 6 if $handler_code =~ /\{['"]*form['"]*\}/
522 0 30 if (@{$route->{'params'};})
527 0 30 if (@{$route->{'before'};} or @{$route->{'after'};})
533 1 14 if ($self->{'_session_enabled'})
538 0 15 if ($self->{'_compression_enabled'})
546 0 15 if ($self->{'_async_enabled'})
547 0 0 if ($^O eq 'MSWin32') { }
559 0 1 if (builtin::blessed($mw) and $mw->can('build_before') || $mw->can('build_after')) { }
566 0 1 if (builtin::blessed($mw) and $mw->can('build_before') || $mw->can('build_after')) { }
589 0 0 unless $mw->can("slot_requirements")
592 0 0 if exists $middleware_slots{$name}
608 13 2 if (@methods == 1)
614 7 8 if (@paths > 1)
616 0 7 if (length $prefix > 1)
639 24 6 if (not $route->{'dynamic'}) { }
641 0 24 if ($route->{'_static_file'})
648 0 24 if ($route->{'need_xs_builder'})
661 1 23 if (ref $result eq 'ARRAY') { }
8 15 elsif (ref $result eq 'HASH') { }
675 1 23 unless defined $body and not ref $body
680 23 0 $self->{'enable_security_headers'} ? :
706 2 12 if ($self->{'route_analysis'}{'needs_streaming'})
709 2 2 unless $route->{'dynamic'}
710 2 0 $route->{'streaming'} ? :
716 0 14 if ($self->_has_websocket_routes)
723 0 0 if ($route->{'opts'}{'rooms'})
737 0 14 if ($self->{'websocket_rooms'})
743 0 14 if ($analysis->{'has_route_middleware'})
747 0 0 unless $route->{'dynamic'}
758 1 13 if ($analysis->{'has_global_before'} or $analysis->{'has_global_after'})
793 14 0 defined $Config::Config{'archname'} ? :
796 14 0 if (eval { do { require Digest::MD5; 1 } }) { }
822 2 12 if ($self->{'route_analysis'}{'needs_streaming'})
828 0 14 if ($self->{'route_analysis'}{'needs_websocket'})
834 0 14 if ($self->{'route_analysis'}{'needs_websocket_handler'})
840 0 14 if ($self->{'route_analysis'}{'needs_websocket_rooms'})
846 0 14 if ($self->{'route_analysis'}{'needs_async_pool'})
856 0 14 if (my $xsr = $self->{'_xs_builder_routes'})
861 0 0 if ($result->{'xs_functions'})
875 0 14 if ($self->{'tls'})
881 0 14 if ($self->{'http2'})
890 0 14 if ($self->{'_compression_enabled'})
898 0 14 if ($self->{'route_analysis'}{'needs_async_pool'})
904 14 0 if ($self->{'_event_backend'})
906 14 0 if ($backend->can("extra_cflags"))
908 0 14 if $ev_cflags
911 14 0 if ($backend->can("extra_ldflags"))
913 0 14 if $ev_ldflags
921 0 14 if ($^O eq "MSWin32")
923 0 0 unless $ld =~ /-lws2_32\b/
931 14 0 if ($ENV{'HYPERSONIC_COMPILE_DIAG'} or $ENV{'AUTOMATED_TESTING'})
950 0 14 unless $ok
963 0 14 unless defined &{"${module_name}::dispatch";}
968 0 14 if ($self->{'route_analysis'}{'needs_async_pool'})
1039 0 14 if ($self->{'_compression_enabled'})
1045 0 14 if ($self->{'tls'})
1051 0 14 if ($self->{'http2'})
1070 3 11 if ($self->{'enable_security_headers'} and $has_dynamic)
1096 0 14 if (my $helpers = $self->{'c_helpers'})
1098 0 0 if (ref $helpers eq 'CODE') { }
1121 0 14 if ($self->{'_compression_enabled'})
1192 0 14 if ($self->{'tls'})
1205 0 14 if ($self->{'http2'})
1221 2 12 if ($analysis->{'needs_streaming'})
1235 0 14 if ($analysis->{'needs_websocket'})
1252 0 14 if ($analysis->{'needs_websocket_handler'})
1260 0 14 if ($analysis->{'needs_websocket_rooms'})
1269 0 14 if ($analysis->{'needs_async_pool'})
1283 0 14 if ($analysis->{'needs_xs_builder'})
1287 0 0 unless $route->{'need_xs_builder'}
1296 0 0 unless ref $result eq "HASH" and $result->{'xs_function'}
1309 0 0 if (@xs_builder_routes)
1323 0 14 if ($analysis->{'needs_websocket'})
1330 3 11 if ($has_dynamic)
1336 1 2 if ($analysis->{'has_any_middleware'})
1374 2 0 if ($analysis->{'needs_streaming'} and $self->{'_streaming_flags'})
1384 0 0 if ($analysis->{'needs_websocket'} and $self->{'_websocket_paths'})
1394 0 0 $i < $#paths ? :
1414 14 0 $self->{'enable_security_headers'} ? :
1426 3 11 if ($self->{'enable_security_headers'} and $has_dynamic)
1432 3 11 if ($has_dynamic)
1438 0 0 if ($analysis->{'needs_xs_builder'} and $self->{'_xs_builder_routes'} and @{$self->{'_xs_builder_routes'};})
1444 0 14 if ($analysis->{'needs_websocket'})
1472 23 6 if (not $r->{'dynamic'}) { }
1487 0 6 if ($r->{'need_xs_builder'} and $r->{'_xs_result'}) { }
0 6 elsif ($path =~ /:(\w+)/) { }
1491 0 0 if ($path =~ /:(\w+)/) { }
1685 3 11 if ($has_dynamic) { }
1698 1 2 if ($analysis->{'has_any_middleware'})
1703 1 0 if ($analysis->{'has_global_before'})
1710 1 0 if ($analysis->{'has_global_after'})
1719 0 1 if ($analysis->{'has_route_middleware'})
1740 0 14 if ($analysis->{'needs_websocket'})
1764 0 14 if ($self->{'tls'})
1785 0 14 if ($analysis->{'needs_async_pool'})
1794 0 14 if ($backend_name eq 'kqueue') { }
14 0 elsif ($backend_name eq 'epoll') { }
0 0 elsif ($backend_name eq 'io_uring') { }
1912 0 14 if ($analysis->{'needs_async_pool'})
1940 0 14 if ($analysis->{'needs_websocket'})
1955 0 14 if ($analysis->{'needs_websocket'})
1968 0 14 if ($analysis->{'needs_websocket'})
1981 3 11 if ($has_dynamic) { }
1983 0 3 if ($analysis->{'needs_xs_builder'} and $self->{'_xs_builder_routes'} and @{$self->{'_xs_builder_routes'};}) { }
2031 0 14 if ($analysis->{'needs_websocket'})
2045 0 14 if ($analysis->{'needs_async_pool'})
2063 0 0 unless @$xs_routes
2161 0 3 if ($analysis->{'needs_query'} or $analysis->{'needs_form'})
2221 0 2 if ($analysis->{'needs_headers'} or $analysis->{'needs_cookies'} or $analysis->{'needs_json'} or $analysis->{'needs_form'})
2258 0 3 if ($analysis->{'has_builder_before'} or $analysis->{'has_builder_after'})
2263 0 0 if $seen_classes{$class}++
2264 0 0 if ($mw->can("build_helpers"))
2272 1 2 if ($analysis->{'has_any_middleware'})
2397 0 3 if ($analysis->{'needs_query'}) { }
2421 1 2 if ($needs_header_parse) { }
2429 1 0 if ($analysis->{'needs_cookies'}) { }
2464 1 0 if ($analysis->{'needs_form'} or $analysis->{'needs_json'}) { }
2471 0 1 if ($analysis->{'needs_form'}) { }
2483 1 0 if ($analysis->{'needs_json'}) { }
2537 0 3 if ($analysis->{'has_builder_before'})
2546 0 0 if ($mw->can("build_before"))
2553 1 2 if ($analysis->{'has_global_before'})
2567 0 3 if ($analysis->{'has_route_middleware'})
2587 2 1 if ($analysis->{'needs_streaming'})
2610 1 2 if ($analysis->{'has_any_middleware'}) { }
2618 0 1 if ($analysis->{'needs_streaming'})
2633 2 0 if ($analysis->{'needs_streaming'})
2643 0 3 if ($analysis->{'has_route_middleware'})
2662 1 2 if ($analysis->{'has_global_after'})
2675 0 3 if ($analysis->{'has_builder_after'})
2685 0 0 if ($mw->can("build_after"))
2692 2 1 if ($analysis->{'needs_streaming'})
2719 1 2 if ($analysis->{'has_any_middleware'}) { }
2780 0 3 if ($self->{'_compression_enabled'})
2893 1 2 if ($analysis->{'has_any_middleware'}) { }
3163 0 6 unless ref $coderef eq "CODE"
3166 3 3 unless $DEPARSER
3170 0 6 $@ ? :
3176 0 7 unless @paths
3177 0 7 if @paths == 1
3183 0 44 if $prefix eq ""
3188 0 7 if (not $prefix =~ m[/$] and $prefix =~ m[^(.*/)[^/]+$])
3253 0 0 unless -f $_
3263 0 0 unless open my $fh, "<:raw", $file_path
3273 0 0 if ($gen_etag)
3307 0 0 if $max_age
3308 0 0 if $etag
3311 0 0 if ($self->{'enable_security_headers'})
3343 120 160 unless defined $value and length $value
3353 0 3 unless $self->{'enable_security_headers'}
3356 0 3 unless length $headers
3365 1 30 unless $self->{'compiled'}
3372 1 0 unless $self->{'compiled'}
3383 0 0 if ($^O eq "MSWin32" and $workers > 1)
3389 0 0 $self->{'tls'} ? :
0 0 $self->{'http2'} ? :
3395 0 0 if ($workers > 1)
3398 0 0 unless (defined $pid)
3401 0 0 if ($pid == 0)
3404 0 0 if $listen_fd < 0
3413 0 0 if $listen_fd < 0