File Coverage

blib/lib/Feersum/Connection.pm
Criterion Covered Total %
statement 30 35 85.7
branch n/a
condition n/a
subroutine 10 15 66.6
pod 5 5 100.0
total 45 55 81.8


line stmt bran cond sub pod time code
1             package Feersum::Connection;
2 30     30   231 use warnings;
  30         61  
  30         1055  
3 30     30   193 use strict;
  30         57  
  30         670  
4 30     30   144 use Carp qw/croak/;
  30         64  
  30         1892  
5 30     30   2233 use IO::Socket::INET;
  30         66617  
  30         431  
6              
7             sub new {
8 0     0 1 0 croak "Cannot instantiate Feersum::Connection directly";
9             }
10              
11             sub read_handle {
12 0     0 1 0 croak "read_handle is deprecated; use psgi.input instead";
13             }
14              
15             sub write_handle {
16 0     0 1 0 croak "write_handle is deprecated; ".
17             "use return value from start_streaming instead";
18             }
19              
20             sub start_response {
21 0     0 1 0 croak "start_response is deprecated; ".
22             "use start_streaming() or start_whole_response() instead";
23             }
24              
25             sub initiate_streaming {
26 0     0 1 0 croak "initiate_streaming is deprecated; ".
27             "use start_streaming() and its return value instead";
28             }
29              
30             sub _initiate_streaming_psgi {
31 17     17   329318 my ($self, $streamer) = @_;
32 17     9   140 return $streamer->(sub { $self->_continue_streaming_psgi(@_) });
  9         236440  
33             }
34              
35             my $_pkg = "Feersum::";
36             sub _raw { ## no critic (RequireArgUnpacking)
37             # don't shift; want to modify $_[0] directly.
38 8     8   180 my $fileno = $_[1];
39 8         21 my $name = "RAW$fileno";
40             # Hack to make gensyms via new_from_fd() show up in the Feersum package.
41             # This may or may not save memory (HEKs?) over true gensyms.
42 30     30   26258 no warnings 'redefine';
  30         85  
  30         1893  
43             local *IO::Handle::gensym = sub {
44 30     30   183 no strict;
  30         56  
  30         3303  
45 8     8   57 my $gv = \*{$_pkg.$name};
  8         40  
46 8         20 delete $$_pkg{$name};
47 8         17 $gv;
48 8         78 };
49             # Replace $_[0] directly:
50 8         55 $_[0] = IO::Socket::INET->new_from_fd($fileno, '+<');
51             # after this, Feersum will use PerlIO_unread to put any remainder data
52             # into the socket.
53 8         635 return;
54             }
55             1;
56             __END__