2 HTTP::Body - HTTP Body Parser
8 my ( $class, $r ) = @_;
10 my $content_type = $r->headers_in->get('Content-Type');
11 my $content_length = $r->headers_in->get('Content-Length');
13 my $body = HTTP::Body->new( $content_type, $content_length );
14 my $length = $content_length;
18 $r->read( my $buffer, ( $length < 8192 ) ? $length : 8192 );
20 $length -= length($buffer);
25 my $uploads = $body->upload; # hashref
26 my $params = $body->param; # hashref
27 my $body = $body->body; # IO::Handle
31 HTTP::Body parses chunks of HTTP POST data and supports
32 application/octet-stream, application/x-www-form-urlencoded, and
35 Chunked bodies are supported by not passing a length value to new().
37 It is currently used by Catalyst to parse POST bodies.
40 When parsing multipart bodies, temporary files are created to store any
41 uploaded files. You must delete these temporary files yourself after
45 new Constructor. Takes content type and content length as parameters,
46 returns a HTTP::Body object.
48 add Add string to internal buffer. Will call spin unless done. returns
49 length before adding self.
52 accessor for the body.
55 Returns 1 if the request is chunked.
58 Returns the content-length for the body data if known. Returns -1 if
59 the request is chunked.
62 Returns the content-type of the body data.
68 Returns the total length of data we expect to read if known. In the
69 case of a chunked request, returns the amount of data read so far.
72 If a chunked request body had trailing headers, trailing_headers
73 will return an HTTP::Headers object populated with those headers.
76 Abstract method to spin the io handle.
79 Returns the current state of the parser.
82 Get/set body parameters.
88 Specify a different path for temporary files. Defaults to the system
92 Christian Hansen, "ch@ngmedia.com"
94 Sebastian Riedel, "sri@cpan.org"
96 Andy Grundman, "andy@hybridized.org"
99 This library is free software. You can redistribute it and/or modify it
100 under the same terms as perl itself.