Improved tests
[catagits/HTTP-Request-AsCGI.git] / t / 06response.t
CommitLineData
ca38286c 1#!perl
2
3use Test::More tests => 8;
4
5use strict;
6use warnings;
7
8use IO::File;
9use HTTP::Request;
10use HTTP::Request::AsCGI;
11
12my $response;
13
14{
15 my $r = HTTP::Request->new( GET => 'http://www.host.com/' );
16 my $c = HTTP::Request::AsCGI->new($r);
17
18 $c->setup;
19
20 print "HTTP/1.0 200 OK\n";
21 print "Content-Type: text/plain\n";
22 print "Status: 200\n";
23 print "X-Field: 1\n";
24 print "X-Field: 2\n";
25 print "\n";
26 print "Hello!";
27
28 $response = $c->restore->response;
29}
30
31isa_ok( $response, 'HTTP::Response' );
32is( $response->code, 200, 'Response Code' );
33is( $response->message, 'OK', 'Response Message' );
34is( $response->protocol, 'HTTP/1.0', 'Response Protocol' );
35is( $response->content, 'Hello!', 'Response Content' );
36is( $response->content_length, 6, 'Response Content-Length' );
37is( $response->content_type, 'text/plain', 'Response Content-Type' );
38is_deeply( [ $response->header('X-Field') ], [ 1, 2 ], 'Response Header X-Field' );