1HTTP::Body(3)         User Contributed Perl Documentation        HTTP::Body(3)
2
3
4

NAME

6       HTTP::Body - HTTP Body Parser
7

SYNOPSIS

9           use HTTP::Body;
10
11           sub handler : method {
12               my ( $class, $r ) = @_;
13
14               my $content_type   = $r->headers_in->get('Content-Type');
15               my $content_length = $r->headers_in->get('Content-Length');
16
17               my $body   = HTTP::Body->new( $content_type, $content_length );
18               my $length = $content_length;
19
20               while ( $length ) {
21
22                   $r->read( my $buffer, ( $length < 8192 ) ? $length : 8192 );
23
24                   $length -= length($buffer);
25
26                   $body->add($buffer);
27               }
28
29               my $uploads = $body->upload; # hashref
30               my $params  = $body->param;  # hashref
31               my $body    = $body->body;   # IO::Handle
32           }
33

DESCRIPTION

35       HTTP::Body parses chunks of HTTP POST data and supports applica‐
36       tion/octet-stream, application/x-www-form-urlencoded, and multi‐
37       part/form-data.
38
39       It is currently used by Catalyst to parse POST bodies.
40

METHODS

42       new Constructor. Takes content type and content length as parameters,
43           returns a HTTP::Body object.
44
45       add Add string to internal buffer. Will call spin unless done. returns
46           length before adding self.
47
48       body
49           accessor for the body.
50
51       buffer
52           read only accessor for the buffer.
53
54       content_length
55           read only accessor for content length
56
57       content_type
58           ready only accessor for the content type
59
60       init
61           return self.
62
63       length
64           read only accessor for body length.
65
66       spin
67           Abstract method to spin the io handle.
68
69       state
70           accessor for body state.
71
72       param
73           accesor for http parameters.
74
75       upload
76

BUGS

78       Chunked requests are currently not supported.
79

AUTHOR

81       Christian Hansen, "ch@ngmedia.com"
82
83       Sebastian Riedel, "sri@cpan.org"
84

LICENSE

86       This library is free software. You can redistribute it and/or modify it
87       under the same terms as perl itself.
88
89
90
91perl v5.8.8                       2007-03-27                     HTTP::Body(3)
Impressum