line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MVC::Neaf::Request::FakeWriter; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
36
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
162
|
|
4
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1301
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.2800_01'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MVC::Neaf::Request::FakeWriter - part of test suite for Not Even A Framework |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
See L and L. |
14
|
|
|
|
|
|
|
Unless you plan to contribute to framework itself, this module is useless. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This module converts L asynchronous response with callback to a normal |
17
|
|
|
|
|
|
|
straightforward response ([status, header, content]). |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SINOPSYS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Data::Dumper; |
22
|
|
|
|
|
|
|
use MVC::Neaf::Request::FakeWriter; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $capture = MVC::Neaf::Request::FakeWriter->new; |
25
|
|
|
|
|
|
|
my $result = $capture->respond( $psgi_app_return ); |
26
|
|
|
|
|
|
|
warn Dumper( $result ); # normal PSGI response |
27
|
|
|
|
|
|
|
# aka [ status, [ head...], [content...] ] |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 new |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Constructor (no args). |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 respond( sub { ... } ) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Respond to provided callback in PSGI-compatible manner. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 write( $data ) |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Append given data to buffer. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 close() |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Do nothing. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new { |
50
|
5
|
|
|
5
|
1
|
51
|
return bless {}, shift; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub respond { |
54
|
5
|
|
|
5
|
1
|
14
|
my ($self, $psgi_ret) = @_; |
55
|
|
|
|
|
|
|
|
56
|
5
|
50
|
|
|
|
20
|
return $psgi_ret if ref $psgi_ret eq 'ARRAY'; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$psgi_ret->( sub { |
59
|
5
|
|
|
5
|
|
8
|
my $resp = shift; |
60
|
5
|
|
|
|
|
30
|
$self->{status} = $resp->[0]; |
61
|
5
|
|
|
|
|
11
|
$self->{header} = $resp->[1]; |
62
|
5
|
|
50
|
|
|
31
|
$self->{content} = $resp->[2] || []; |
63
|
|
|
|
|
|
|
|
64
|
5
|
|
|
|
|
15
|
return $self; |
65
|
5
|
|
|
|
|
34
|
} ); |
66
|
|
|
|
|
|
|
|
67
|
5
|
|
|
|
|
37
|
return [ $self->{status}, $self->{header}, $self->{content} ]; |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub write { |
71
|
49
|
|
|
49
|
1
|
90
|
my ($self, $data) = @_; |
72
|
49
|
|
|
|
|
62
|
push @{ $self->{content} }, $data; |
|
49
|
|
|
|
|
155
|
|
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
7
|
1
|
|
sub close { |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This module is part of L suite. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Copyright 2016-2023 Konstantin S. Uvarin C. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
85
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
86
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
See L for more information. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |