7 # The test functions are placed here to make things easier
9 use DebbugsTest qw(:all);
15 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
19 %config = create_debbugs_configuration();
24 $ENV{DEBBUGS_CONFIG_FILE} = "$config{config_dir}/debbugs_config";
26 my $libravatar_cgi_handler = sub {
28 $ENV{DEBBUGS_CONFIG_FILE} = $config{config_dir}."/debbugs_config";
29 open($fh,'-|',-e './cgi/libravatar.cgi'? './cgi/libravatar.cgi'
30 : '../cgi/libravatar.cgi');
34 if (/^\s*$/ and $status) {
35 print "HTTP/1.1 $status OK\n";
41 if (/^Status:\s*(\d+)/i) {
51 ok(DebbugsTest::HTTPServer::fork_and_create_webserver($libravatar_cgi_handler,$port),
52 'forked HTTP::Server::Simple successfully');
55 my $ua = LWP::UserAgent->new;
56 $ua->agent("DebbugsTesting/0.1 ");
59 my $req = HTTP::Request->new(GET => "http://localhost:$port/?avatar=no");
61 my $res = $ua->request($req);
62 ok($res->is_success(),'cgi/libravatar.cgi returns success');
63 my $etag = $res->header('Etag');
65 $req = HTTP::Request->new(GET => "http://localhost:$port/?avatar=no",
66 ['If-None-Match',$etag]);
67 $res = $ua->request($req);
68 ok($res->code() eq '304','If-None-Match set gives us 304 not modified');