| 1 |
NAME |
| 2 |
|
| 3 |
POE::Filter::HTTP::Parser - A HTTP POE filter for HTTP clients or |
| 4 |
servers |
| 5 |
|
| 6 |
VERSION |
| 7 |
|
| 8 |
version 1.08 |
| 9 |
|
| 10 |
SYNOPSIS |
| 11 |
|
| 12 |
use POE::Filter::HTTP::Parser; |
| 13 |
|
| 14 |
# For HTTP Servers |
| 15 |
|
| 16 |
my $request_filter = POE::Filter::HTTP::Parser->new( type => 'server' ); |
| 17 |
my $arrayref_of_request_objects = $filter->get( [ $stream ] ); |
| 18 |
|
| 19 |
my $arrayref_of_HTTP_stream = $filter->put( $arrayref_of_response_objects ); |
| 20 |
|
| 21 |
# For HTTP clients |
| 22 |
|
| 23 |
my $response_filter = POE::Filter::HTTP::Parser->new( type => 'client' ); |
| 24 |
my $arrayref_of_HTTP_stream = $filter->put( $arrayref_of_request_objects ); |
| 25 |
|
| 26 |
my $arrayref_of_response_objects = $filter->get( [ $stream ] ); |
| 27 |
|
| 28 |
DESCRIPTION |
| 29 |
|
| 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 will |
| 36 |
parse HTTP::Response objects from HTTP streams and put will accept |
| 37 |
HTTP::Request objects and convert them to HTTP streams. |
| 38 |
|
| 39 |
With the type set to server, the reverse will happen. get will parse |
| 40 |
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 |
|
| 47 |
CONSTRUCTOR |
| 48 |
|
| 49 |
new |
| 50 |
|
| 51 |
Creates a new POE::Filter::HTTP::Parser object. Takes one optional |
| 52 |
argument, type which determines whether the filter will act in client |
| 53 |
or server mode. client is the default if type is not specified. |
| 54 |
|
| 55 |
'type', set to either 'client' or 'server', default is 'client'; |
| 56 |
|
| 57 |
METHODS |
| 58 |
|
| 59 |
get |
| 60 |
|
| 61 |
get_one_start |
| 62 |
|
| 63 |
get_one |
| 64 |
|
| 65 |
Takes an arrayref which contains lines of text. Returns an arrayref |
| 66 |
of either HTTP::Request or HTTP::Response objects depending on the |
| 67 |
type that has been specified. |
| 68 |
|
| 69 |
get_pending |
| 70 |
|
| 71 |
Returns any data remaining in a filter's input buffer. The filter's |
| 72 |
input buffer is not cleared, however. Returns an array reference if |
| 73 |
there's any data, or undef if the filter was empty. |
| 74 |
|
| 75 |
put |
| 76 |
|
| 77 |
Takes an arrayref of either HTTP::Response objects or HTTP::Request |
| 78 |
objects depending on whether type is set to server or client, |
| 79 |
respectively. |
| 80 |
|
| 81 |
If type is client, then this accepts HTTP::Request objects. If type |
| 82 |
is server, then this accepts HTTP::Response objects. |
| 83 |
|
| 84 |
This does make sense if you think about it. |
| 85 |
|
| 86 |
The given objects are returned to their stream form. |
| 87 |
|
| 88 |
clone |
| 89 |
|
| 90 |
Makes a copy of the filter, and clears the copy's buffer. |
| 91 |
|
| 92 |
CREDITS |
| 93 |
|
| 94 |
The put method for HTTP responses was borrowed from POE::Filter::HTTPD, |
| 95 |
along with the code to generate HTTP::Response on a parse error, by |
| 96 |
Artur Bergman and Rocco Caputo. |
| 97 |
|
| 98 |
SEE ALSO |
| 99 |
|
| 100 |
POE::Filter |
| 101 |
|
| 102 |
HTTP::Parser |
| 103 |
|
| 104 |
POE::Filter::HTTPD |
| 105 |
|
| 106 |
AUTHOR |
| 107 |
|
| 108 |
Chris Williams <[email protected]> |
| 109 |
|
| 110 |
COPYRIGHT AND LICENSE |
| 111 |
|
| 112 |
This software is copyright (c) 2016 by Chris Williams, Artur Bergman |
| 113 |
and Rocco Caputo. |
| 114 |
|
| 115 |
This is free software; you can redistribute it and/or modify it under |
| 116 |
the same terms as the Perl 5 programming language system itself. |
| 117 |
|