HTTP::Body, changed to version 0.03 since we it's got a major bug fix
[catagits/HTTP-Body.git] / README
CommitLineData
aac7ca02 1NAME
2 HTTP::Body - HTTP Body Parser
3
4SYNOPSIS
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
30DESCRIPTION
31 HTTP Body Parser.
32
33METHODS
09abe57d 34 new Constructor. Takes content type and content length as parameters,
35 returns a HTTP::Body object.
36
37 add Add string to itnernal buffer. Will call spin unless done. returns
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
69AUTHOR
70 Christian Hansen, "ch@ngmedia.com"
71
09abe57d 72 Sebastian Riedel, "sri@cpan.org"
73
aac7ca02 74LICENSE
09abe57d 75 This library is free software. You can redistribute it and/or modify it
aac7ca02 76 under the same terms as perl itself.
77