File: 39_httpoxy.t

package info (click to toggle)
libfurl-perl 3.14-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 660 kB
  • sloc: perl: 2,188; makefile: 5; sh: 1
file content (61 lines) | stat: -rw-r--r-- 1,496 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use strict;
use warnings;
use Furl::HTTP;
use Test::More;

plan tests => 8;

sub test_proxy {
  my $expect = shift;
  my $client = Furl::HTTP->new->env_proxy;
  $client->{proxy};
}

undef $ENV{REQUEST_METHOD};
undef $ENV{HTTP_PROXY};
undef $ENV{http_proxy};
is test_proxy, '';

$ENV{REQUEST_METHOD} = 'GET';
undef $ENV{HTTP_PROXY};
undef $ENV{http_proxy};
is test_proxy, '';

SKIP: {
    skip 'skip Windows', 1 if $^O eq 'MSWin32';
    undef $ENV{REQUEST_METHOD};
    $ENV{HTTP_PROXY} = 'http://proxy1.example.com';
    undef $ENV{http_proxy};
    is test_proxy, 'http://proxy1.example.com';
}

$ENV{REQUEST_METHOD} = 'GET';
$ENV{HTTP_PROXY} = 'http://proxy1.example.com';
undef $ENV{http_proxy};
is test_proxy, '';

undef $ENV{REQUEST_METHOD};
undef $ENV{HTTP_PROXY};
$ENV{http_proxy} = 'http://proxy2.example.com';
is test_proxy, 'http://proxy2.example.com';

SKIP: {
    skip 'skip Windows', 1 if $^O eq 'MSWin32';
    $ENV{REQUEST_METHOD} = 'GET';
    undef $ENV{HTTP_PROXY};
    $ENV{http_proxy} = 'http://proxy2.example.com';
    is test_proxy, 'http://proxy2.example.com';
}

undef $ENV{REQUEST_METHOD};
$ENV{HTTP_PROXY} = 'http://proxy1.example.com';
$ENV{http_proxy} = 'http://proxy2.example.com';
is test_proxy, 'http://proxy2.example.com';

SKIP: {
    skip 'skip Windows', 1 if $^O eq 'MSWin32';
    $ENV{REQUEST_METHOD} = 'GET';
    $ENV{HTTP_PROXY} = 'http://proxy1.example.com';
    $ENV{http_proxy} = 'http://proxy2.example.com';
    is test_proxy, 'http://proxy2.example.com';
}