NAME
HTTP::Request::Diff - create diffs between HTTP requests
SYNOPSIS
my $diff = HTTP::Request::Diff->new(
reference => $req,
#actual => $req2,
skip_headers => \@skip,
ignore_headers => \@skip2,
mode => 'exact', # default is 'semantic'
);
my @differences = $diff->diff( $actual );
say Dumper $differences[0];
# {
# 'kind' => 'value',
# 'type' => 'query.foo',
# 'reference' => [
# undef
# ],
# 'actual' => [
# 'bar'
# ]
# }
#
METHODS
->new
my $diff = HTTP::Request::Diff->new(
mode => 'semantic',
);
Options
-
modemode => 'strict',The comparison mode. The default is semantic comparison, which considers some differences insignificant:
- The order of HTTP headers
- The boundary strings of multipart POST requests
- The order of query parameters
- The order of form parameters
- A
Content-Length: 0header is equivalent to a missingContent-Lengthheader
strictmode wants the requests to be as identical as possible.laxmode considers query parameters in the POST body as equivalent. -
reference(optional) The reference request to compare against. Alternatively pass in the request in the call to
->diff. -
skip_headersskip_headers => ['X-Proxied-For'],List of headers to skip when comparing. Missing headers are not significant.
-
ignore_headersignore_headers => ['Accept-Encoding'],List of headers to ignore when comparing. Missing headers are significant.
-
canonicalizeCallback to canonicalize a request. The request will be passed in unmodified either as a string or a HTTP::Request.
-
compareArrayref of things to compare.
-
warn_on_newlines(optional) If we should output warnings when we receive
\ndelimited input instead of\r\n. This mostly happens when input is read from text files for regression test.Default is true.
->diff
my @diff = $diff->diff( $reference, $actual, %options );
my @diff = $diff->diff( $actual, %options );
Performs the diff and returns an array of hashrefs with differences.
->as_table( @diff )
my @diff = $diff->diff( $request1, $request2 );
print $diff->as_table( @diff );
# +-----------------+-----------+--------+
# | Type | Reference | Actual |
# +-----------------+-----------+--------+
# | request.content | Ümloud | Umloud |
# +-----------------+-----------+--------+
Renders a diff as a table, using Term::Table.
REPOSITORY
The public repository of this module is https://github.com/Corion/HTTP-Request-Diff.
SUPPORT
The public support forum of this module is https://perlmonks.org/.
BUG TRACKER
Please report bugs in this module via the Github bug queue at https://github.com/Corion/HTTP-Request-Diff/issues
AUTHOR
Max Maischein corion@cpan.org
COPYRIGHT (c)
Copyright 2023- by Max Maischein corion@cpan.org.
LICENSE
This module is released under the same terms as Perl itself.