HTTP::Parser::XS - a fast, primitive HTTP request parser
use HTTP::Parser::XS qw(parse_http_request); my $ret = parse_http_request( "GET / HTTP/1.0\r\nHost: ...\r\n\r\n", \%env, ); if ($ret == -2) { # request is incomplete ... } elsif ($ret == -1) { # request is broken ... } else { # $ret includes the size of the request, %env now contains a PSGI # request, if it is a POST / PUT request, read request content by # yourself ... }
HTTP::Parser::XS is a fast, primitive HTTP request parser that can be used either for writing a synchronous HTTP server or a event-driven server.
Tries to parse given request string, and if successful, inserts variables into %env. For the name of the variables inserted, please refer to the PSGI specification. The return values are:
length of the request (request line and the request headers), in bytes
given request is corrupt
given request is incomplete
Kazuho Oku <kazuhooku@gmail.com>
HTTP::Parser HTTP::HeaderParser::XS
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install HTTP::Parser::XS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Parser::XS
CPAN shell
perl -MCPAN -e shell install HTTP::Parser::XS
For more information on module installation, please visit the detailed CPAN module installation guide.