File: 08error.t

package info (click to toggle)
libhttp-request-ascgi-perl 1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 156 kB
  • ctags: 7
  • sloc: perl: 461; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (7)
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
#!perl

use Test::More tests => 12;

use strict;
use warnings;

use IO::File;
use HTTP::Request;
use HTTP::Request::AsCGI;

my $response;

{
    my $r = HTTP::Request->new( GET => 'http://www.host.com/' );
    my $c = HTTP::Request::AsCGI->new($r);

    $c->setup;

    $response = $c->restore->response;
}

isa_ok( $response, 'HTTP::Response' );
is( $response->code, 500, 'Response Code' );
is( $response->message, 'Internal Server Error', 'Response Message' );
is( $response->protocol, 'HTTP/1.1', 'Response Protocol' );
is( $response->content_type, 'text/html', 'Response Content-Type' );
ok( length($response->content) > 0, 'Response Content' );

{
    my $r = HTTP::Request->new( GET => 'http://www.host.com/' );
    my $c = HTTP::Request::AsCGI->new($r);

    $c->setup;
    
    print "Content-Type: text/plain\n";
    print "Status: 500 Borked\n";
    print "\n";
    print "Borked!";

    $response = $c->restore->response;
}

isa_ok( $response, 'HTTP::Response' );
is( $response->code, 500, 'Response Code' );
is( $response->message, 'Borked', 'Response Message' );
is( $response->protocol, 'HTTP/1.1', 'Response Protocol' );
is( $response->content_type, 'text/plain', 'Response Content-Type' );
is( $response->content, 'Borked!', 'Response Content' );