NAME

HTTP::Lint - Check HTTP messages and transactions for protocol violations

SYNOPSIS

use HTTP::Lint qw/http_lint/;
use HTTP::Request;
use HTTP::Response;

my $request = parse HTTP::Request ($q);
my $response = parse HTTP::Request ($r);

# Check request
warn $_ foreach http_lint ($request);

# Check response, treat warnings as fatal
foreach http_lint ($response) {
    die $_ if ref $_ eq 'HTTP::Lint::Error';
    warn $_ if ref $_ eq 'HTTP::Lint::Warning';
}

# Construct a transaction and check it
$response->request ($request);
warn $_ foreach http_lint ($response);

DESCRIPTION

HTTP::Lint checks for protocol violation and suspicious or ambigious stuff in HTTP messages and transactions. It produces errors and warning, loosely corresponsing to MUST and SHOULD clauses in RFC2616 (HTTP/1.1 specification).

SUBROUTINES

http_lint [MESSAGE]

Checks an instance of a subclass of HTTP::Message: a HTTP::Response or a HTTP::Request. If a HTTP::Response is given, and it contains a valid request associated, the request is checked too and a transaction check is done to check whether the response is appropriate for the request.

Result of the call is an array of arrayrefs blessed with HTTP::Lint::Error or HTTP::Lint::Warning package. The first element of the message is the message string, the second one is the arrayref of section numbers that refer to RFC2616:

bless [ '418 Response from what is not a teapot',
    [ 666,1,2,3 ] ], 'HTTP::Lint::Error';

You can stringify the message or call the method pretty to pretty-format the message.

request_lint [REQUEST]

Only check a HTTP::Request.

The return value follows the same rules as of http_lint.

response_lint [REQUEST]

Only check a HTTP::Response.

The return value follows the same rules as of http_lint.

transaction_lint [REQUEST] [RESPONSE]

Only check a relation between HTTP::Request and HTTP::Response.

The return value follows the same rules as of http_lint.

SEE ALSO

BUGS

Probably many!

The set of checks is very incomplete and some are likely wrong and produce false positives.

Contributions, patches and bug reports are more than welcome.

COPYRIGHT

Copyright 2011, Lubomir Rintel

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Lubomir Rintel lkundrak@v3.sk