HTTP::HeaderParser::XS - an XS extension for processing HTTP headers.


HTTP-HeaderParser-XS documentation  | view source Contained in the HTTP-HeaderParser-XS distribution.

Index


NAME

Top

HTTP::HeaderParser::XS - an XS extension for processing HTTP headers.

SYNOPSIS

Top

  use HTTP::HeaderParser::XS;

  my $hdr = HTTP::HeaderParser::XS->new( \"GET / HTTP/1.0\r\nConnection: keep-alive\r\nHost: www.bar.com\r\n\r\n" );

  if ( $hdr->isResponse ) {
    # this is not a response in this simple demo, but it could be
    print "Response code: " . $hdr->getStatusCode . "\n";
    print "Connection header: " . $hdr->getHeader( 'Connection' ) . "\n";

  } else {
    # see if it's a GET request
    if ( $hdr->getMethod == M_GET ) {
      print "GET: " . $hdr->getURI() . "\n";

      # now let's rewrite the host header and rewrite the header :-)
      print "Host header was: " . $hdr->getHeader( 'Host' ) . "\n";
      $hdr->setHeader( 'Host', 'www.foo.com' );

      # show new headers, now that we changed something
      print "New headers:\n";
      print $hdr->getReconstructed . "\n";

    } else {
      print "Not a GET request!\n";
    }
  }

DESCRIPTION

Top

This module parses HTTP headers using a C++ state machine. (Hence this being an XS module.) The goal is to be fast, not necessarily to do everything you could ever want.

Headers are not static, you can parse them, munge them, or even build them using this module. See the SYNOPSIS for more information on how to use this module.

KNOWN BUGS

Top

There are no known bugs at this time. Please report any you find!

SEE ALSO

Top

There is no place designated for support of this module. If you would like to contact the author, please see the email address below. Or, find him on the Perl IRC network as 'xb95', usually in various channels.

AUTHOR

Top

Mark Smith, <mark@xb95.com>

COPYRIGHT AND LICENSE

Top


HTTP-HeaderParser-XS documentation  | view source Contained in the HTTP-HeaderParser-XS distribution.