~ubuntu-branches/ubuntu/wily/libwww-perl/wily

« back to all changes in this revision

Viewing changes to t/base/http-config.t

  • Committer: Bazaar Package Importer
  • Author(s): Nicholas Bamber
  • Date: 2011-04-02 15:13:32 UTC
  • mfrom: (1.4.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20110402151332-tpkr18gfx51ccjn2
Tags: 6.01-1
* New upstream release 
  - Modules not in the LWP namespace have been made into separate modules
  - In particular IPv6 issues now handled by libnet-http-perl,
    see #306914, (Closes: #614948) 
  - Packages using HTTP::Daemon should declare the appropriate
    dependency on libhttp-daemon-perl | libwww-perl (<< 6).
  - Packages using HTML::Form should declare the appropriate
    dependency on libhtml-form-perl | libwww-perl (<< 6).
  - Other depending packages can safely continue to depend on libwww-perl,
    but in some cases may be able to tighten up their dependencies.
  - LWP::Protocol::https will be split off in the next release
    so now liblwp-protocol-https-perl is Provided.
* Updated dependencies
* New upstream release
* Removed unnecessary versioned dependency on libio-compress-perl
* Patched LWP::Protocol::https to use ca-certificates rather than 
  Mozilla::CA (Closes: #619059)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!perl -w
2
 
 
3
 
use strict;
4
 
use Test;
5
 
plan tests => 14;
6
 
 
7
 
use HTTP::Config;
8
 
 
9
 
sub j { join("|", @_) }
10
 
 
11
 
my $conf = HTTP::Config->new;
12
 
ok($conf->empty);
13
 
$conf->add_item(42);
14
 
ok(!$conf->empty);
15
 
ok(j($conf->matching_items("http://www.example.com/foo")), 42);
16
 
ok(j($conf->remove_items), 42);
17
 
ok($conf->matching_items("http://www.example.com/foo"), 0);
18
 
 
19
 
$conf = HTTP::Config->new;
20
 
 
21
 
$conf->add_item("always");
22
 
$conf->add_item("GET", m_method => ["GET", "HEAD"]);
23
 
$conf->add_item("POST", m_method => "POST");
24
 
$conf->add_item(".com", m_domain => ".com");
25
 
$conf->add_item("secure", m_secure => 1);
26
 
$conf->add_item("not secure", m_secure => 0);
27
 
$conf->add_item("slash", m_host_port => "www.example.com:80", m_path_prefix => "/");
28
 
$conf->add_item("u:p", m_host_port => "www.example.com:80", m_path_prefix => "/foo");
29
 
$conf->add_item("success", m_code => "2xx");
30
 
 
31
 
use HTTP::Request;
32
 
my $request = HTTP::Request->new(HEAD => "http://www.example.com/foo/bar");
33
 
$request->header("User-Agent" => "Moz/1.0");
34
 
 
35
 
ok(j($conf->matching_items($request)), "u:p|slash|.com|GET|not secure|always");
36
 
 
37
 
$request->method("HEAD");
38
 
$request->uri->scheme("https");
39
 
 
40
 
ok(j($conf->matching_items($request)), ".com|GET|secure|always");
41
 
 
42
 
ok(j($conf->matching_items("http://activestate.com")), ".com|not secure|always");
43
 
 
44
 
use HTTP::Response;
45
 
my $response = HTTP::Response->new(200 => "OK");
46
 
$response->content_type("text/plain");
47
 
$response->content("Hello, world!\n");
48
 
$response->request($request);
49
 
 
50
 
ok(j($conf->matching_items($response)), ".com|success|GET|secure|always");
51
 
 
52
 
$conf->remove_items(m_secure => 1);
53
 
$conf->remove_items(m_domain => ".com");
54
 
ok(j($conf->matching_items($response)), "success|GET|always");
55
 
 
56
 
$conf->remove_items;  # start fresh
57
 
ok(j($conf->matching_items($response)), "");
58
 
 
59
 
$conf->add_item("any", "m_media_type" => "*/*");
60
 
$conf->add_item("text", m_media_type => "text/*");
61
 
$conf->add_item("html", m_media_type => "html");
62
 
$conf->add_item("HTML", m_media_type => "text/html");
63
 
$conf->add_item("xhtml", m_media_type => "xhtml");
64
 
 
65
 
ok(j($conf->matching_items($response)), "text|any");
66
 
 
67
 
$response->content_type("application/xhtml+xml");
68
 
ok(j($conf->matching_items($response)), "xhtml|html|any");
69
 
 
70
 
$response->content_type("text/html");
71
 
ok(j($conf->matching_items($response)), "HTML|html|text|any");