.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "POE::Filter::HTTP::Parser 3pm" .TH POE::Filter::HTTP::Parser 3pm "2022-06-17" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" POE::Filter::HTTP::Parser \- A HTTP POE filter for HTTP clients or servers .SH "VERSION" .IX Header "VERSION" version 1.08 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use POE::Filter::HTTP::Parser; \& \& # For HTTP Servers \& \& my $request_filter = POE::Filter::HTTP::Parser\->new( type => \*(Aqserver\*(Aq ); \& my $arrayref_of_request_objects = $filter\->get( [ $stream ] ); \& \& my $arrayref_of_HTTP_stream = $filter\->put( $arrayref_of_response_objects ); \& \& # For HTTP clients \& \& my $response_filter = POE::Filter::HTTP::Parser\->new( type => \*(Aqclient\*(Aq ); \& my $arrayref_of_HTTP_stream = $filter\->put( $arrayref_of_request_objects ); \& \& my $arrayref_of_response_objects = $filter\->get( [ $stream ] ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" POE::Filter::HTTP::Parser is a POE::Filter for \s-1HTTP\s0 which is based on HTTP::Parser. .PP It can be used to easily create \s-1POE\s0 based \s-1HTTP\s0 servers or clients. .PP With the \f(CW\*(C`type\*(C'\fR set to \f(CW\*(C`client\*(C'\fR, which is the default behaviour, \f(CW\*(C`get\*(C'\fR will parse HTTP::Response objects from \s-1HTTP\s0 streams and \f(CW\*(C`put\*(C'\fR will accept HTTP::Request objects and convert them to \s-1HTTP\s0 streams. .PP With the \f(CW\*(C`type\*(C'\fR set to \f(CW\*(C`server\*(C'\fR, the reverse will happen. \f(CW\*(C`get\*(C'\fR will parse HTTP::Request objects from \s-1HTTP\s0 streams and \f(CW\*(C`put\*(C'\fR will accept HTTP::Response objects and convert them to \&\s-1HTTP\s0 streams. Like POE::Filter::HTTPD if there is an error parsing the \s-1HTTP\s0 request, this filter will generate a HTTP::Response object instead, to encapsulate the error message, suitable for simply sending back to the requesting client. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .ie n .IP """new""" 4 .el .IP "\f(CWnew\fR" 4 .IX Item "new" Creates a new POE::Filter::HTTP::Parser object. Takes one optional argument, \f(CW\*(C`type\*(C'\fR which determines whether the filter will act in \f(CW\*(C`client\*(C'\fR or \f(CW\*(C`server\*(C'\fR mode. \f(CW\*(C`client\*(C'\fR is the default if \f(CW\*(C`type\*(C'\fR is not specified. .Sp .Vb 1 \& \*(Aqtype\*(Aq, set to either \*(Aqclient\*(Aq or \*(Aqserver\*(Aq, default is \*(Aqclient\*(Aq; .Ve .SH "METHODS" .IX Header "METHODS" .ie n .IP """get""" 4 .el .IP "\f(CWget\fR" 4 .IX Item "get" .PD 0 .ie n .IP """get_one_start""" 4 .el .IP "\f(CWget_one_start\fR" 4 .IX Item "get_one_start" .ie n .IP """get_one""" 4 .el .IP "\f(CWget_one\fR" 4 .IX Item "get_one" .PD Takes an arrayref which contains lines of text. Returns an arrayref of either HTTP::Request or HTTP::Response objects depending on the \f(CW\*(C`type\*(C'\fR that has been specified. .ie n .IP """get_pending""" 4 .el .IP "\f(CWget_pending\fR" 4 .IX Item "get_pending" Returns any data remaining in a filter's input buffer. The filter's input buffer is not cleared, however. Returns an array reference if there's any data, or undef if the filter was empty. .ie n .IP """put""" 4 .el .IP "\f(CWput\fR" 4 .IX Item "put" Takes an arrayref of either HTTP::Response objects or HTTP::Request objects depending on whether \&\f(CW\*(C`type\*(C'\fR is set to \f(CW\*(C`server\*(C'\fR or \f(CW\*(C`client\*(C'\fR, respectively. .Sp If \f(CW\*(C`type\*(C'\fR is \f(CW\*(C`client\*(C'\fR, then this accepts HTTP::Request objects. If \f(CW\*(C`type\*(C'\fR is \f(CW\*(C`server\*(C'\fR, then this accepts HTTP::Response objects. .Sp This does make sense if you think about it. .Sp The given objects are returned to their stream form. .ie n .IP """clone""" 4 .el .IP "\f(CWclone\fR" 4 .IX Item "clone" Makes a copy of the filter, and clears the copy's buffer. .SH "CREDITS" .IX Header "CREDITS" The \f(CW\*(C`put\*(C'\fR method for \s-1HTTP\s0 responses was borrowed from POE::Filter::HTTPD, along with the code to generate HTTP::Response on a parse error, by Artur Bergman and Rocco Caputo. .SH "SEE ALSO" .IX Header "SEE ALSO" POE::Filter .PP HTTP::Parser .PP POE::Filter::HTTPD .SH "AUTHOR" .IX Header "AUTHOR" Chris Williams .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2016 by Chris Williams, Artur Bergman and Rocco Caputo. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.