Corion / HTTP-Request-Diff

HTTP::Request::Diff - diff two HTTP requests
Artistic License 2.0
0 stars 0 forks source link

Windows MacOS Linux

NAME

HTTP::Request::Diff - create diffs between HTTP requests

SYNOPSIS

use HTTP::Request::Common 'GET';

my $diff = HTTP::Request::Diff->new(
    reference => GET('https://example.com/?foo=bar' ),
    #actual    => $req2,
    skip_headers => \@skip,
    ignore_headers => \@skip2,
    mode => 'exact', # default is 'semantic'
);

my @differences = $diff->diff( GET('https://example.com/' ));
say Dumper $differences[0];
# {
#   'kind' => 'value',
#   'type' => 'query.foo',
#   'reference' => [
#                    'bar'
#                  ],
#   'actual' => [
#                 undef
#               ]
# }
#

say $diff->as_table(@differences);
# +-----------+-----------+-----------+
# | Type      | Reference | Actual    |
# +-----------+-----------+-----------+
# | query.foo | bar       | <missing> |
# +-----------+-----------+-----------+

METHODS

->new

my $diff = HTTP::Request::Diff->new(
    mode => 'semantic',
);

Options

->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 Artistic License 2.0.