NAME
HTTP::Parser::XS - a fast, primitive HTTP request parser
SYNOPSIS
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
...
}
DESCRIPTION
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.
METHODS
parse_http_request($request_string, \%env)
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:
>=0 length of the request (request line and the request
headers), in bytes
-1 given request is corrupt
-2 given request is incomplete
COPYRIGHT
Copyright 2009- Kazuho Oku
AUTHOR
Kazuho Oku
THANKS TO
nothingmuch charsbar
SEE ALSO
HTTP::Parser HTTP::HeaderParser::XS
LICENSE
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.