File: author-30.max-redirects.t

package info (click to toggle)
libwww-curl-simple-perl 0.100191-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 240 kB
  • sloc: perl: 685; makefile: 4
file content (42 lines) | stat: -rw-r--r-- 797 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl -w

BEGIN {
  unless ($ENV{AUTHOR_TESTING}) {
    require Test::More;
    Test::More::plan(skip_all => 'these tests are for testing by the author');
  }
}


use strict;
use Test::More tests => 3;
use WWW::Curl::Simple;

my $url = 'http://httpstat.us/302';
my $curl;
my $response;

{
    $curl     = WWW::Curl::Simple->new(max_redirects => 0);
    $response = $curl->get($url);
    ok($response->code == 302);
}

# be nice to httpstat.us
sleep(1);

{
    $curl     = WWW::Curl::Simple->new(max_redirects => 1);
    $response = $curl->get($url);
    ok($response->code == 200);
}

# be nice to httpstat.us
sleep(1);

{
    # default is 5 redirects, so this should work too
    $curl     = WWW::Curl::Simple->new();
    $response = $curl->get($url);
    ok($response->code == 200);
}