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 version 1.08
11
13 use POE::Filter::HTTP::Parser;
14
15 # For HTTP Servers
16
17 my $request_filter = POE::Filter::HTTP::Parser->new( type => 'server' );
18 my $arrayref_of_request_objects = $filter->get( [ $stream ] );
19
20 my $arrayref_of_HTTP_stream = $filter->put( $arrayref_of_response_objects );
21
22 # For HTTP clients
23
24 my $response_filter = POE::Filter::HTTP::Parser->new( type => 'client' );
25 my $arrayref_of_HTTP_stream = $filter->put( $arrayref_of_request_objects );
26
27 my $arrayref_of_response_objects = $filter->get( [ $stream ] );
28
30 POE::Filter::HTTP::Parser is a POE::Filter for HTTP which is based on
31 HTTP::Parser.
32
33 It can be used to easily create POE based HTTP servers or clients.
34
35 With the "type" set to "client", which is the default behaviour, "get"
36 will parse HTTP::Response objects from HTTP streams and "put" will
37 accept HTTP::Request objects and convert them to HTTP streams.
38
39 With the "type" set to "server", the reverse will happen. "get" will
40 parse HTTP::Request objects from HTTP streams and "put" will accept
41 HTTP::Response objects and convert them to HTTP streams. Like
42 POE::Filter::HTTPD if there is an error parsing the HTTP request, this
43 filter will generate a HTTP::Response object instead, to encapsulate
44 the error message, suitable for simply sending back to the requesting
45 client.
46
48 "new"
49 Creates a new POE::Filter::HTTP::Parser object. Takes one optional
50 argument, "type" which determines whether the filter will act in
51 "client" or "server" mode. "client" is the default if "type" is not
52 specified.
53
54 'type', set to either 'client' or 'server', default is 'client';
55
57 "get"
58 "get_one_start"
59 "get_one"
60 Takes an arrayref which contains lines of text. Returns an arrayref
61 of either HTTP::Request or HTTP::Response objects depending on the
62 "type" that has been specified.
63
64 "get_pending"
65 Returns any data remaining in a filter's input buffer. The filter's
66 input buffer is not cleared, however. Returns an array reference
67 if there's any data, or undef if the filter was empty.
68
69 "put"
70 Takes an arrayref of either HTTP::Response objects or HTTP::Request
71 objects depending on whether "type" is set to "server" or "client",
72 respectively.
73
74 If "type" is "client", then this accepts HTTP::Request objects. If
75 "type" is "server", then this accepts HTTP::Response objects.
76
77 This does make sense if you think about it.
78
79 The given objects are returned to their stream form.
80
81 "clone"
82 Makes a copy of the filter, and clears the copy's buffer.
83
85 The "put" method for HTTP responses was borrowed from
86 POE::Filter::HTTPD, along with the code to generate HTTP::Response on a
87 parse error, by Artur Bergman and Rocco Caputo.
88
90 POE::Filter
91
92 HTTP::Parser
93
94 POE::Filter::HTTPD
95
97 Chris Williams <chris@bingosnet.co.uk>
98
100 This software is copyright (c) 2016 by Chris Williams, Artur Bergman
101 and Rocco Caputo.
102
103 This is free software; you can redistribute it and/or modify it under
104 the same terms as the Perl 5 programming language system itself.
105
106
107
108perl v5.34.0 2021-07-22 POE::Filter::HTTP::Parser(3)