Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 56 lines (44 sloc) 1.504 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
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.
Something went wrong with that request. Please try again.