#!perl
-use Test::More tests => 9;
+use Test::More tests => 16;
use strict;
use warnings;
{
my $r = HTTP::Request->new( GET => 'http://www.host.com/' );
- my $c = HTTP::Request::AsCGI->new( request => $r );
+ my $c = HTTP::Request::AsCGI->new($r);
$c->setup;
-
+
print "Content-Type: text/plain\n";
print "Status: 200 Yay\n";
print "Date: Thu, 19 Jan 2006 14:08:18 GMT\n";
is( $response->content_type, 'text/plain', 'Response Content-Type' );
is( $response->header('Date'), 'Thu, 19 Jan 2006 14:08:18 GMT', 'Response Date' );
is_deeply( [ $response->header('X-Field') ], [ 1, 2 ], 'Response Header X-Field' );
+
+
+# test with a crappy cgi that doesn't actually print any headers. actually works
+{
+ my $r = HTTP::Request->new( GET => 'http://www.host.com/' );
+ my $c = HTTP::Request::AsCGI->new($r);
+
+ $c->setup;
+
+ print "Look at me I am crappy and don't have any headers.";
+
+ $response = $c->restore->response;
+}
+
+isa_ok( $response, 'HTTP::Response' );
+is( $response->code, 200, 'Response Code' );
+is( $response->message, 'OK', 'Response Message' );
+is( $response->protocol, 'HTTP/1.1', 'Response Protocol' );
+is( $response->content, "Look at me I am crappy and don't have any headers.", 'Response Content' );
+is( $response->content_length, 50, 'Response Content-Length is right!' );
+is( $response->content_type, '', 'Response Content-Type is blank' );