Commit | Line | Data |
---|---|---|
aac7ca02 | 1 | NAME |
2 | HTTP::Body - HTTP Body Parser | |
3 | ||
4 | SYNOPSIS | |
5 | use HTTP::Body; | |
09abe57d | 6 | |
7 | sub handler : method { | |
8 | my ( $class, $r ) = @_; | |
9 | ||
10 | my $content_type = $r->headers_in->get('Content-Type'); | |
11 | my $content_length = $r->headers_in->get('Content-Length'); | |
12 | ||
13 | my $body = HTTP::Body->new( $content_type, $content_length ); | |
14 | my $length = $content_length; | |
15 | ||
16 | while ( $length ) { | |
17 | ||
18 | $r->read( my $buffer, ( $length < 8192 ) ? $length : 8192 ); | |
19 | ||
20 | $length -= length($buffer); | |
21 | ||
22 | $body->add($buffer); | |
23 | } | |
24 | ||
25 | my $uploads = $body->upload; # hashref | |
26 | my $params = $body->param; # hashref | |
27 | my $body = $body->body; # IO::Handle | |
28 | } | |
aac7ca02 | 29 | |
30 | DESCRIPTION | |
31 | HTTP Body Parser. | |
32 | ||
33 | METHODS | |
09abe57d | 34 | new Constructor. Takes content type and content length as parameters, |
35 | returns a HTTP::Body object. | |
36 | ||
40a213fd | 37 | add Add string to internal buffer. Will call spin unless done. returns |
09abe57d | 38 | length before adding self. |
39 | ||
aac7ca02 | 40 | body |
09abe57d | 41 | accessor for the body. |
42 | ||
aac7ca02 | 43 | buffer |
09abe57d | 44 | read only accessor for the buffer. |
45 | ||
aac7ca02 | 46 | content_length |
09abe57d | 47 | read only accessor for content length |
48 | ||
aac7ca02 | 49 | content_type |
09abe57d | 50 | ready only accessor for the content type |
51 | ||
aac7ca02 | 52 | init |
09abe57d | 53 | return self. |
54 | ||
aac7ca02 | 55 | length |
09abe57d | 56 | read only accessor for body length. |
57 | ||
aac7ca02 | 58 | spin |
09abe57d | 59 | Abstract method to spin the io handle. |
60 | ||
aac7ca02 | 61 | state |
09abe57d | 62 | accessor for body state. |
63 | ||
aac7ca02 | 64 | param |
09abe57d | 65 | accesor for http parameters. |
66 | ||
aac7ca02 | 67 | upload |
68 | ||
40a213fd | 69 | BUGS |
70 | Chunked requests are currently not supported. | |
71 | ||
aac7ca02 | 72 | AUTHOR |
73 | Christian Hansen, "ch@ngmedia.com" | |
74 | ||
09abe57d | 75 | Sebastian Riedel, "sri@cpan.org" |
76 | ||
aac7ca02 | 77 | LICENSE |
09abe57d | 78 | This library is free software. You can redistribute it and/or modify it |
aac7ca02 | 79 | under the same terms as perl itself. |
80 |