1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use HTTPTest;
7
8
9###############################################################################
10
11my $mainpage = <<EOF;
12<html>
13<head>
14  <title>Main Page Title</title>
15</head>
16<body>
17  <a href="http://localhost:{{port}}/subpage.php">Secondary Page</a>
18</body>
19</html>
20EOF
21
22my $mainpagemangled = <<EOF;
23<html>
24<head>
25  <title>Main Page Title</title>
26</head>
27<body>
28  <a href="subpage.php.html">Secondary Page</a>
29</body>
30</html>
31EOF
32
33my $subpage = <<EOF;
34<html>
35<head>
36  <title>Secondary Page Title</title>
37</head>
38<body>
39  <p>Some text</p>
40</body>
41</html>
42EOF
43
44# code, msg, headers, content
45my %urls = (
46    '/index.php' => {
47        code => "200",
48        msg => "Dontcare",
49        headers => {
50            "Content-type" => "text/html",
51        },
52        content => $mainpage,
53    },
54    '/subpage.php' => {
55        code => "200",
56        msg => "Dontcare",
57        headers => {
58            "Content-type" => "text/html",
59        },
60        content => $subpage,
61    },
62);
63
64my $cmdline = $WgetTest::WGETPATH . " -d -r -nd -E -k -K http://localhost:{{port}}/index.php";
65
66my $expected_error_code = 0;
67
68my %expected_downloaded_files = (
69    'index.php.orig' => {
70        content => $mainpage,
71    },
72    'index.php.html' => {
73        content => $mainpagemangled,
74    },
75    'subpage.php.html' => {
76        content => $subpage,
77    },
78);
79
80###############################################################################
81
82my $the_test = HTTPTest->new (name => "Test-E-k-K",
83                              input => \%urls,
84                              cmdline => $cmdline,
85                              errcode => $expected_error_code,
86                              output => \%expected_downloaded_files);
87exit $the_test->run();
88
89# vim: et ts=4 sw=4
90
91