1POE::Filter::HTTP::ParsUesre(r3)Contributed Perl DocumenPtOaEt:i:oFnilter::HTTP::Parser(3)
2
3
4
6 POE::Filter::HTTP::Parser - A HTTP POE filter for HTTP clients or
7 servers
8
10 use POE::Filter::HTTP::Parser;
11
12 # For HTTP Servers
13
14 my $request_filter = POE::Filter::HTTP::Parser->new( type => 'server' );
15 my $arrayref_of_request_objects = $filter->get( [ $stream ] );
16
17 my $arrayref_of_HTTP_stream = $filter->put( $arrayref_of_response_objects );
18
19 # For HTTP clients
20
21 my $response_filter = POE::Filter::HTTP::Parser->new( type => 'client' );
22 my $arrayref_of_HTTP_stream = $filter->put( $arrayref_of_request_objects );
23
24 my $arrayref_of_response_objects = $filter->get( [ $stream ] );
25
27 POE::Filter::HTTP::Parser is a POE::Filter for HTTP which is based on
28 HTTP::Parser.
29
30 It can be used to easily create POE based HTTP servers or clients.
31
32 With the "type" set to "client", which is the default behaviour, "get"
33 will parse HTTP::Response objects from HTTP streams and "put" will
34 accept HTTP::Request objects and convert them to HTTP streams.
35
36 With the "type" set to "server", the reverse will happen. "get" will
37 parse HTTP::Request objects from HTTP streams and "put" will accept
38 HTTP::Response objects and convert them to HTTP streams. Like
39 POE::Filter::HTTPD if there is an error parsing the HTTP request, this
40 filter will generate a HTTP::Response object instead, to encapsulate
41 the error message, suitable for simply sending back to the requesting
42 client.
43
45 "new"
46 Creates a new POE::Filter::HTTP::Parser object. Takes one optional
47 argument, "type" which determines whether the filter will act in
48 "client" or "server" mode. "client" is the default if "type" is not
49 specified.
50
51 'type', set to either 'client' or 'server', default is 'client';
52
54 "get"
55 "get_one_start"
56 "get_one"
57 Takes an arrayref which contains lines of text. Returns an arrayref
58 of either HTTP::Request or HTTP::Response objects depending on the
59 "type" that has been specified.
60
61 "get_pending"
62 Returns any data remaining in a filter's input buffer. The filter's
63 input buffer is not cleared, however. Returns an array reference
64 if there's any data, or undef if the filter was empty.
65
66 "put"
67 Takes an arrayref of either HTTP::Response objects or HTTP::Request
68 objects depending on whether "type" is set to "server" or "client",
69 respectively.
70
71 If "type" is "client", then this accepts HTTP::Request objects. If
72 "type" is "server", then this accepts HTTP::Response objects.
73
74 This does make sense if you think about it.
75
76 The given objects are returned to their stream form.
77
78 "clone"
79 Makes a copy of the filter, and clears the copy's buffer.
80
82 Chris "BinGOs" Williams
83
84 The "put" method for HTTP responses was borrowed from
85 POE::Filter::HTTPD, along with the code to generate HTTP::Response on a
86 parse error, by Artur Bergman and Rocco Caputo.
87
89 Copyright X Chris Williams, Artur Bergman and Rocco Caputo.
90
91 This module may be used, modified, and distributed under the same terms
92 as Perl itself. Please see the license that came with your Perl
93 distribution for details.
94
96 POE::Filter
97
98 HTTP::Parser
99
100 POE::Filter::HTTPD
101
102
103
104perl v5.12.1 2009-06-17 POE::Filter::HTTP::Parser(3)