| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTTP::Server::Simple::Dispatched::Request; |
|
2
|
1
|
|
|
1
|
|
5487
|
use HTTP::Request; |
|
|
1
|
|
|
|
|
75702
|
|
|
|
1
|
|
|
|
|
46
|
|
|
3
|
1
|
|
|
1
|
|
11
|
use base qw(HTTP::Request); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
523
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=pod |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This built by HTTP::Server::Simple::Dispatched to avoid reading the |
|
10
|
|
|
|
|
|
|
entity-body of a message if it is never asked for. You likely don't want to |
|
11
|
|
|
|
|
|
|
use it directly |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 METHODS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 new |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Because it's convenient, any field you can set on a normal Request object can be passed as a keyword parameter here, and the normal constructor with positional arguments is ignored. In addition, a handle parameter is passed in - this is the file handle from which to read the entity-body of the request. A Content-Length header must be present, or content will be empty. This is not standards compliant at all, and will likely change in future versions. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
|
22
|
0
|
|
|
0
|
1
|
|
my ($class, %opts) = @_; |
|
23
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(); |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
foreach my $arg (keys %opts) { |
|
26
|
0
|
0
|
|
|
|
|
if (my $setter = $self->can($arg)) { |
|
27
|
0
|
|
|
|
|
|
$setter->($self, $opts{$arg}); |
|
28
|
0
|
|
|
|
|
|
delete $opts{$arg}; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$self->{_handle} = $opts{handle}; |
|
33
|
0
|
|
|
|
|
|
return bless $self, $class; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 read_content |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This forces the content to be read from the provided filehandle: this should be called if you're planning on storing the request, as the filehandle will become invalid after the request is handled. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub read_content { |
|
43
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
44
|
0
|
|
0
|
|
|
|
my $handle = (delete $self->{_handle}) || return; |
|
45
|
0
|
|
|
|
|
|
my $content = q(); |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
0
|
|
|
|
my $to_read = $self->content_length || return; |
|
48
|
0
|
|
|
|
|
|
while (my $bytes_read = sysread($handle, my $buffer, $to_read)) { |
|
49
|
0
|
|
|
|
|
|
$to_read -= $bytes_read; |
|
50
|
0
|
|
|
|
|
|
$content .= $buffer; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
0
|
|
|
|
|
|
$self->content_length($self->content_length - $to_read); |
|
53
|
0
|
|
|
|
|
|
$self->content($content); |
|
54
|
0
|
|
|
|
|
|
delete $self->{_handle}; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 content |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub content { |
|
62
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
63
|
0
|
|
|
|
|
|
$self->read_content; |
|
64
|
0
|
|
|
|
|
|
$self->SUPER::content(@_); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 content_ref |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
These both force read_content to be called, but otherwise are identical to the |
|
70
|
|
|
|
|
|
|
parent class's. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub content_ref { |
|
75
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
76
|
0
|
|
|
|
|
|
$self->read_content; |
|
77
|
0
|
|
|
|
|
|
$self->SUPER::content_ref(@_); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Paul Driver, C<< <frodwith at cpan.org> >> |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 BUGS |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-http-server-simple-dispatched at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTTP-Server-Simple-Dispatched>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L<HTTP::Request>, L<HTTP::Server::Simple::Dispatched> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Copyright 2008 Paul Driver, all rights reserved. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |