Skip to content

Commit

Permalink
Merge 826e0b7 into 66e6639
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Sep 23, 2020
2 parents 66e6639 + 826e0b7 commit d1f9300
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Change history for libwww-perl

{{$NEXT}}
- Require network testing enabled for t/redirect.t (GH#351) (Olaf Alders)

6.48 2020-09-20 15:25:51Z
- Support 308 Permanent Redirect (GH#349) (Galen Huntington)
Expand Down
36 changes: 29 additions & 7 deletions t/redirect.t
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
use strict;
use warnings;

# This is a regression test for #171

use Test::More;

use LWP::UserAgent;
plan tests => 4;
# Test::RequiresInternet is used here basically just to SKIP tests if
# NO_NETWORK_TESTING has been enabled. We would want to do this particularly if
# there is a badly behaved router on the network where the tests are being run.
use Test::RequiresInternet;

# This is a regression test for #171
use LWP::UserAgent ();

# Regarding the choice of 198.51.100.123 as a test IP address, please see
# https://tools.ietf.org/html/rfc5737
#
# The RFC contains the following description for the block to which this
# address belongs:
#
# Documentation Address Blocks
#
# The blocks 192.0.2.0/24 (TEST-NET-1), 198.51.100.0/24 (TEST-NET-2), and
# 203.0.113.0/24 (TEST-NET-3) are provided for use in documentation.

my $url = 'http://198.51.100.123/';

my $ua = LWP::UserAgent->new();

{ # default number of redirects
# default number of redirects
{
$ua->timeout(1);
my $res = $ua->get('http://198.51.100.123/');
my $res = $ua->get($url);
like(
$res->header("Client-Warning"),
qr/Internal Response/i,
Expand All @@ -24,10 +43,11 @@ my $ua = LWP::UserAgent->new();
);
}

{ # no redirects
# no redirects
{
$ua->timeout(1);
$ua->max_redirect(0);
my $res = $ua->get('http://198.51.100.123/');
my $res = $ua->get($url);
like(
$res->header("Client-Warning"),
qr/Internal Response/i,
Expand All @@ -39,3 +59,5 @@ my $ua = LWP::UserAgent->new();
'... and has tells us about the problem'
);
}

done_testing();

0 comments on commit d1f9300

Please sign in to comment.