SimpleHTTP/Response.pm

filter: Statementstmt 81.8% 36 / 44 Branchbran 25.0% 1 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 88.8% 8 / 9 Podpod 50.0% 1 / 2 totaltotal 74.1% 46 / 62 CC 4 SCAR 10.2
CC
4
Cov
74%
stream
7.4
new
2.0
BEGIN
1.0
CRAP 2.8
« SimpleHTTP/Connection.pm ↑ Summary SimpleHTTP/State.pm »
1 package POE::Component::Server::SimpleHTTP::Response;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 our $VERSION = '2.24';
7  
8 7 ▶use base qw( HTTP::Response );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 extends qw(HTTP::Response Moose::Object );
12  
13 7 has '_WHEEL' => (
14 is => 'rw',
15 );
16  
17 7 has 'connection' => (
18 is => 'ro',
19 writer => 'set_connection',
20 );
21  
22 7 has 'STREAM_SESSION' => (
23 is => 'rw',
24 );
25  
26 7 has 'STREAM' => (
27 is => 'rw',
28 );
29  
30 has 'STREAM_DONE' => (
31 is => 'ro',
32 6 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
33 7 writer => 'set_stream_done',
34 init_arg => undef,
35 );
36  
37 7 has 'IS_STREAMING' => (
38 is => 'ro',
39 writer => 'set_streaming',
40 );
41  
42 7 has 'DONT_FLUSH' => (
43 is => 'rw',
44 isa => 'Bool',
45 );
46  
47 sub new {
48 6 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod documented
49  
50 # Get the Wheel ID
51 6 my $wid = shift;
52  
53 # Get the Connection object
54 6 my $conn = shift;
55  
56 # Make sure we got the wheel ID!
57 6 ▶ if ( !defined $wid ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $wid) 0 6 6
58 0 die 'Did not get a Wheel ID!';
59 }
60  
61 6 my $self = $class->SUPER::new(@_);
62  
63 6 return $class->meta->new_object(
64 __INSTANCE__ => $self,
65 _WHEEL => $wid,
66 connection => $conn,
67 );
68 }
69  
70 sub stream {
71 0 ▶ my $self = shift;
Subroutine stream: not called CC=3 SCAR=20.0
Pod undocumented
72 0 my %opt = (@_);
73  
74 7 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
75  
76 0 ▶ if ( $opt{event} ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{'event'} ne '') { } 0 0 0
77 0 ▶ $self->STREAM_SESSION( $opt{'session'} || undef );
Condition0%0/2
$opt{'session'} || undef
l!l
00
MC/DC0%0/1
$opt{'session'} || undef
$opt{'session'}
Truth table0%0/2
A
A= $opt{'session'}
Aresult
11
00
78 0 $self->STREAM( $opt{'event'} );
79 0 $self->DONT_FLUSH( $opt{'dont_flush'} );
80 }
81 else {
82 0 $self->STREAM( shift );
83 }
84 }
85  
86 7 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 7 __PACKAGE__->meta->make_immutable( inline_constructor => 0 );
89  
90 # End of module
91 7 1;
92  
93 __END__
94  
95 =head1 NAME
96  
97 POE::Component::Server::SimpleHTTP::Response - Emulates a HTTP::Response object, used for SimpleHTTP
98  
99 =head1 SYNOPSIS
100  
101 use POE::Component::Server::SimpleHTTP::Response;
102 my $response = POE::Component::Server::SimpleHTTP::Response->new( $wheel_id, $connection );
103  
104 print $response->connection->remote_ip;
105  
106 =head1 DESCRIPTION
107  
108 This module is used as a drop-in replacement, because we need to store the wheel ID + connection object for the response.
109  
110 Use $response->connection to get the SimpleHTTP::Connection object
111  
112 =head2 EXPORT
113  
114 Nothing.
115  
116 =head1 SEE ALSO
117  
118 L<POE::Component::Server::SimpleHTTP>
119  
120 L<POE::Component::Server::SimpleHTTP::Connection>
121  
122 =head1 AUTHOR
123  
124 Apocalypse E<lt>apocal@cpan.orgE<gt>
125  
126 =head1 COPYRIGHT AND LICENSE
127  
128 Copyright 2006 by Apocalypse
129  
130 This library is free software; you can redistribute it and/or modify
131 it under the same terms as Perl itself.
132  
133 =cut
« SimpleHTTP/Connection.pm ↑ Summary SimpleHTTP/State.pm »