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 22     22   150 use warnings;
  22         37  
  22         778  
3 22     22   111 use strict;
  22         38  
  22         487  
4 22     22   103 use Carp qw/croak/;
  22         39  
  22         1180  
5 22     22   144 use IO::Socket::INET;
  22         84  
  22         313  
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 13     13   181624 my ($self, $streamer) = @_;
32 13     5   109 return $streamer->(sub { $self->_continue_streaming_psgi(@_) });
  5         1073770  
33             }
34              
35             my $_pkg = "Feersum::";
36             sub _raw { ## no critic (RequireArgUnpacking)
37             # don't shift; want to modify $_[0] directly.
38 8     8   141 my $fileno = $_[1];
39 8         17 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 22     22   17358 no warnings 'redefine';
  22         57  
  22         1302  
43             local *IO::Handle::gensym = sub {
44 22     22   143 no strict;
  22         41  
  22         2421  
45 8     8   57 my $gv = \*{$_pkg.$name};
  8         42  
46 8         19 delete $$_pkg{$name};
47 8         20 $gv;
48 8         70 };
49             # Replace $_[0] directly:
50 8         49 $_[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         600 return;
54             }
55             1;
56             __END__