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   206 use warnings;
  30         57  
  30         1152  
3 30     30   246 use strict;
  30         60  
  30         727  
4 30     30   148 use Carp qw/croak/;
  30         52  
  30         1974  
5 30     30   2156 use IO::Socket::INET;
  30         66791  
  30         441  
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   330934 my ($self, $streamer) = @_;
32 17     9   158 return $streamer->(sub { $self->_continue_streaming_psgi(@_) });
  9         758836  
33             }
34              
35             my $_pkg = "Feersum::";
36             sub _raw { ## no critic (RequireArgUnpacking)
37             # don't shift; want to modify $_[0] directly.
38 8     8   162 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   25442 no warnings 'redefine';
  30         104  
  30         3243  
43             local *IO::Handle::gensym = sub {
44 30     30   200 no strict;
  30         60  
  30         3389  
45 8     8   130 my $gv = \*{$_pkg.$name};
  8         51  
46 8         20 delete $$_pkg{$name};
47 8         19 $gv;
48 8         82 };
49             # Replace $_[0] directly:
50 8         60 $_[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         678 return;
54             }
55             1;
56             __END__