~ubuntu-branches/ubuntu/raring/libhttp-request-ascgi-perl/raring

« back to all changes in this revision

Viewing changes to t/06response.t

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Krzyzaniak (eloy)
  • Date: 2005-11-16 13:59:02 UTC
  • Revision ID: james.westby@ubuntu.com-20051116135902-mczwe8n9t4ynigrj
Tags: upstream-0.2
ImportĀ upstreamĀ versionĀ 0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!perl
 
2
 
 
3
use Test::More tests => 8;
 
4
 
 
5
use strict;
 
6
use warnings;
 
7
 
 
8
use IO::File;
 
9
use HTTP::Request;
 
10
use HTTP::Request::AsCGI;
 
11
 
 
12
my $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
 
 
31
isa_ok( $response, 'HTTP::Response' );
 
32
is( $response->code, 200, 'Response Code' );
 
33
is( $response->message, 'OK', 'Response Message' );
 
34
is( $response->protocol, 'HTTP/1.0', 'Response Protocol' );
 
35
is( $response->content, 'Hello!', 'Response Content' );
 
36
is( $response->content_length, 6, 'Response Content-Length' );
 
37
is( $response->content_type, 'text/plain', 'Response Content-Type' );
 
38
is_deeply( [ $response->header('X-Field') ], [ 1, 2 ], 'Response Header X-Field' );