[Catalyst-commits] r9864 - in HTTP-Request-AsCGI/trunk: . examples lib/HTTP/Request t t/deprecated

hdp at dev.catalyst.perl.org hdp at dev.catalyst.perl.org
Sun Apr 26 23:01:45 GMT 2009


Author: hdp
Date: 2009-04-27 00:01:45 +0100 (Mon, 27 Apr 2009)
New Revision: 9864

Removed:
   HTTP-Request-AsCGI/trunk/t/02pod.t
   HTTP-Request-AsCGI/trunk/t/04ioscalar.t
   HTTP-Request-AsCGI/trunk/t/04iostring.t
   HTTP-Request-AsCGI/trunk/t/deprecated/04io.t
   HTTP-Request-AsCGI/trunk/t/deprecated/05env.t
   HTTP-Request-AsCGI/trunk/t/deprecated/06response.t
   HTTP-Request-AsCGI/trunk/t/deprecated/07forking.t
   HTTP-Request-AsCGI/trunk/t/deprecated/08error.t
Modified:
   HTTP-Request-AsCGI/trunk/Changes
   HTTP-Request-AsCGI/trunk/MANIFEST.SKIP
   HTTP-Request-AsCGI/trunk/Makefile.PL
   HTTP-Request-AsCGI/trunk/examples/daemon.pl
   HTTP-Request-AsCGI/trunk/examples/synopsis.pl
   HTTP-Request-AsCGI/trunk/lib/HTTP/Request/AsCGI.pm
   HTTP-Request-AsCGI/trunk/t/01use.t
   HTTP-Request-AsCGI/trunk/t/04io.t
   HTTP-Request-AsCGI/trunk/t/05env.t
   HTTP-Request-AsCGI/trunk/t/06response.t
   HTTP-Request-AsCGI/trunk/t/07forking.t
   HTTP-Request-AsCGI/trunk/t/08error.t
Log:
revert all changes since 0.5

Modified: HTTP-Request-AsCGI/trunk/Changes
===================================================================
--- HTTP-Request-AsCGI/trunk/Changes	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/Changes	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,31 +1,20 @@
 This file documents the revision history for Perl extension HTTP::Request::AsCGI.
 
-0.5_01  2009-04-25
-    - Added support for Perl 5.6, by Hans Dieter Pearcey (hdp at cpan.org)
-    - Added support for in-memory filehandles as standard filehandles
-    - Added support for AUTH_TYPE and REMOTE_USER, currently only support 
-      Basic and Digest auth schemes.
-    - Added support for CODE in request content
-    - Constructor parameters has changed, "old" way of invoking constructor has
-      been moved to deprecation. Please see DEPRECATED section in POD.
-    - Added several new options to constructor for more advanced usage
-    - Major cleanup of internals, more readable and maintainable
-    - Fixed PATH_INFO, must not be urlencoded
-
-0.5  2006-01-20
+0.5  2006-01-20 00:00:00 2005
     - Fixed bug where content was overridden on 500 responses.
 
-0.4  2006-01-19
+0.4  2006-01-19 00:00:00 2005
     - Fixed #15999 return a 500 response when message is empty, reported by Chris Dolan <cdolan at cpan.org>
     - Fixed Status header bug
     - Bumped HTTP::Response requirement to 1.53 and drop our own message parsing.
 
-0.3  2006-01-06
+0.3  2006-01-06 00:00:00 2005
     - Silence uninitialized warnings when restoring %ENV
     - Fixed dup and restore of STDIN.
 
-0.2  2005-10-31
+0.2  2005-10-31 00:55:00 2005
     - Added test for response.
 
-0.1  2005-10-21
+0.1  2005-10-21 00:00:00 2005
     - First release.
+

Modified: HTTP-Request-AsCGI/trunk/MANIFEST.SKIP
===================================================================
--- HTTP-Request-AsCGI/trunk/MANIFEST.SKIP	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/MANIFEST.SKIP	2009-04-26 23:01:45 UTC (rev 9864)
@@ -3,7 +3,6 @@
 \bCVS\b
 ,v$
 \B\.svn\b
-\B\.git\b
 
 # Avoid Makemaker generated and utility files.
 \bMakefile$
@@ -24,5 +23,3 @@
 \.bak$
 \#$
 \b\.#
-
-^HTTP-Request-AsCGI-\d

Modified: HTTP-Request-AsCGI/trunk/Makefile.PL
===================================================================
--- HTTP-Request-AsCGI/trunk/Makefile.PL	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/Makefile.PL	2009-04-26 23:01:45 UTC (rev 9864)
@@ -6,12 +6,11 @@
     NAME         => 'HTTP::Request::AsCGI',
     VERSION_FROM => 'lib/HTTP/Request/AsCGI.pm',
     PREREQ_PM    => {
-        'Carp'             => 0,
-        'Class::Accessor'  => 0,
-        'HTTP::Request'    => 0,
-        'HTTP::Response'   => 1.53,
-        'IO::File'         => 0,
-        'Test::More'       => 0,
-        'URI::Escape'      => 0
+        Carp             => 0,
+        Class::Accessor  => 0,        
+        HTTP::Request    => 0,
+        HTTP::Response   => 1.53,
+        IO::File         => 0,
+        Test::More       => 0
     }
 );

Modified: HTTP-Request-AsCGI/trunk/examples/daemon.pl
===================================================================
--- HTTP-Request-AsCGI/trunk/examples/daemon.pl	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/examples/daemon.pl	2009-04-26 23:01:45 UTC (rev 9864)
@@ -18,7 +18,7 @@
 print "Please contact me at: <URL:", $server->url, ">\n";
 
 while ( my $client = $server->accept ) {
-
+    
     my %e = (
         REMOTE_ADDR => $client->peerhost,
         REMOTE_HOST => $client->peerhost,
@@ -53,7 +53,7 @@
               $q->end_form,
               $q->h2('Parameters'),
               $q->Dump,
-              $q->h2('Environment'),
+              $q->h2('Enviroment'),
               $q->table(
                   $q->Tr( [
                       map{ $q->td( [ $_, $ENV{$_} ] ) } sort keys %ENV

Modified: HTTP-Request-AsCGI/trunk/examples/synopsis.pl
===================================================================
--- HTTP-Request-AsCGI/trunk/examples/synopsis.pl	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/examples/synopsis.pl	2009-04-26 23:01:45 UTC (rev 9864)
@@ -21,7 +21,7 @@
 
     $stdout = $c->stdout;
 
-    # environment and descriptors will automatically be restored when $c is destructed.
+    # enviroment and descriptors will automatically be restored when $c is destructed.
 }
 
 while ( my $line = $stdout->getline ) {

Modified: HTTP-Request-AsCGI/trunk/lib/HTTP/Request/AsCGI.pm
===================================================================
--- HTTP-Request-AsCGI/trunk/lib/HTTP/Request/AsCGI.pm	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/lib/HTTP/Request/AsCGI.pm	2009-04-26 23:01:45 UTC (rev 9864)
@@ -5,129 +5,30 @@
 use bytes;
 use base 'Class::Accessor::Fast';
 
-use Carp            qw[croak];
-use HTTP::Response  qw[];
-use IO::File        qw[SEEK_SET];
-use Symbol          qw[];
-use URI::Escape     qw[];
+use Carp;
+use HTTP::Response;
+use IO::Handle;
+use IO::File;
 
-__PACKAGE__->mk_accessors( qw[ is_setup
-                               is_prepared
-                               is_restored
+__PACKAGE__->mk_accessors(qw[ enviroment request stdin stdout stderr ]);
 
-                               should_dup
-                               should_restore
-                               should_rewind
-                               should_setup_content
+our $VERSION = 0.5;
 
-                               environment
-                               request
-                               stdin
-                               stdout
-                               stderr ] );
-
-our $VERSION = 0.5_01;
-
 sub new {
-    my $class  = ref $_[0] ? ref shift : shift;
-    my $params = {};
+    my $class   = shift;
+    my $request = shift;
 
-    if ( @_ % 2 == 0 ) {
-        $params = { @_ };
+    unless ( @_ % 2 == 0 && eval { $request->isa('HTTP::Request') } ) {
+        croak(qq/usage: $class->new( \$request [, key => value] )/);
     }
-    else {
-        $params = { request => shift, environment => { @_ } };
-    }
 
-    return bless( {}, $class )->initialize($params);
-}
+    my $self = $class->SUPER::new( { restored => 0, setuped => 0 } );
+    $self->request($request);
+    $self->stdin( IO::File->new_tmpfile );
+    $self->stdout( IO::File->new_tmpfile );
 
-sub initialize {
-    my ( $self, $params ) = @_;
-
-    if ( exists $params->{request} ) {
-        $self->request( $params->{request} );
-    }
-    else {
-        croak("Mandatory parameter 'request' is missing.");
-    }
-
-    if ( exists $params->{environment} ) {
-        $self->environment( { %{ $params->{environment} } } );
-    }
-    else {
-        $self->environment( {} );
-    }
-
-    if ( exists $params->{stdin} ) {
-        $self->stdin( $params->{stdin} );
-    }
-    else {
-        $self->stdin( IO::File->new_tmpfile );
-    }
-
-    if ( exists $params->{stdout} ) {
-        $self->stdout( $params->{stdout} );
-    }
-    else {
-        $self->stdout( IO::File->new_tmpfile );
-    }
-
-    if ( exists $params->{stderr} ) {
-        $self->stderr( $params->{stderr} );
-    }
-
-    if ( exists $params->{dup} ) {
-        $self->should_dup( $params->{dup} ? 1 : 0 );
-    }
-    else {
-        $self->should_dup(1);
-    }
-
-    if ( exists $params->{restore} ) {
-        $self->should_restore( $params->{restore} ? 1 : 0 );
-    }
-    else {
-        $self->should_restore(1);
-    }
-
-    if ( exists $params->{rewind} ) {
-        $self->should_rewind( $params->{rewind} ? 1 : 0 );
-    }
-    else {
-        $self->should_rewind(1);
-    }
-
-    if ( exists $params->{content} ) {
-        $self->should_setup_content( $params->{content} ? 1 : 0 );
-    }
-    else {
-        $self->should_setup_content(1);
-    }
-
-    $self->prepare;
-
-    return $self;
-}
-
-*enviroment = \&environment;
-
-sub has_stdin  { return defined $_[0]->stdin  }
-sub has_stdout { return defined $_[0]->stdout }
-sub has_stderr { return defined $_[0]->stderr }
-
-my $HTTP_Token   = qr/[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7A\x7C\x7E]/;
-my $HTTP_Version = qr/HTTP\/[0-9]+\.[0-9]+/;
-
-sub prepare {
-    my $self = shift;
-
-    my $environment = $self->environment;
-    my $request     = $self->request;
-
     my $host = $request->header('Host');
     my $uri  = $request->uri->clone;
-
     $uri->scheme('http')    unless $uri->scheme;
     $uri->host('localhost') unless $uri->host;
     $uri->port(80)          unless $uri->port;
@@ -135,11 +36,11 @@
 
     $uri = $uri->canonical;
 
-    my %cgi = (
+    my $enviroment = {
         GATEWAY_INTERFACE => 'CGI/1.1',
         HTTP_HOST         => $uri->host_port,
         HTTPS             => ( $uri->scheme eq 'https' ) ? 'ON' : 'OFF',  # not in RFC 3875
-        PATH_INFO         => URI::Escape::uri_unescape($uri->path),
+        PATH_INFO         => $uri->path,
         QUERY_STRING      => $uri->query || '',
         SCRIPT_NAME       => '/',
         SERVER_NAME       => $uri->host,
@@ -150,454 +51,220 @@
         REMOTE_HOST       => 'localhost',
         REMOTE_PORT       => int( rand(64000) + 1000 ),                   # not in RFC 3875
         REQUEST_URI       => $uri->path_query,                            # not in RFC 3875
-        REQUEST_METHOD    => $request->method
-    );
+        REQUEST_METHOD    => $request->method,
+        @_
+    };
 
-    if ( my $authorization = $request->header('Authorization') ) {
-
-        ( my $scheme ) = $authorization =~ /^($HTTP_Token+)/o;
-
-        if ( $scheme =~ /^Basic/i ) {
-
-            if ( ( my $username ) = $request->headers->authorization_basic ) {
-                $cgi{AUTH_TYPE}   = 'Basic';
-                $cgi{REMOTE_USER} = $username;
-            }
-        }
-        elsif ( $scheme =~ /^Digest/i ) {
-
-            if ( ( my $username ) = $authorization =~ /username="([^"]+)"/ ) {
-                $cgi{AUTH_TYPE}   = 'Digest';
-                $cgi{REMOTE_USER} = $username;
-            }
-        }
-    }
-
-    foreach my $key ( keys %cgi ) {
-
-        unless ( exists $environment->{ $key } ) {
-            $environment->{ $key } = $cgi{ $key };
-        }
-    }
-
     foreach my $field ( $request->headers->header_field_names ) {
 
         my $key = uc("HTTP_$field");
         $key =~ tr/-/_/;
         $key =~ s/^HTTP_// if $field =~ /^Content-(Length|Type)$/;
 
-        unless ( exists $environment->{ $key } ) {
-            $environment->{ $key } = $request->headers->header($field);
+        unless ( exists $enviroment->{$key} ) {
+            $enviroment->{$key} = $request->headers->header($field);
         }
     }
 
-    if ( $environment->{SCRIPT_NAME} ne '/' && $environment->{PATH_INFO} ) {
-        $environment->{PATH_INFO} =~ s/^\Q$environment->{SCRIPT_NAME}\E/\//;
-        $environment->{PATH_INFO} =~ s/^\/+/\//;
+    unless ( $enviroment->{SCRIPT_NAME} eq '/' && $enviroment->{PATH_INFO} ) {
+        $enviroment->{PATH_INFO} =~ s/^\Q$enviroment->{SCRIPT_NAME}\E/\//;
+        $enviroment->{PATH_INFO} =~ s/^\/+/\//;
     }
 
-    $self->is_prepared(1);
+    $self->enviroment($enviroment);
+
+    return $self;
 }
 
 sub setup {
     my $self = shift;
 
-    if ( $self->is_setup ) {
-        croak(   'An attempt was made to setup environment variables and '
-               . 'standard filehandles which has already been setup.' );
-    }
+    $self->{restore}->{enviroment} = {%ENV};
 
-    if ( $self->should_setup_content && $self->has_stdin ) {
-        $self->setup_content;
-    }
+    binmode( $self->stdin );
 
-    if ( $self->has_stdin ) {
+    if ( $self->request->content_length ) {
 
-        if ( $self->should_dup ) {
+        syswrite( $self->stdin, $self->request->content )
+          or croak("Can't write request content to stdin handle: $!");
 
-            if ( $self->should_restore ) {
-
-                open( my $stdin, '<&STDIN' )
-                  or croak("Couldn't dup STDIN: '$!'");
-
-                $self->{restore}->{stdin} = $stdin;
-            }
-
-            open( STDIN, '<&' . fileno($self->stdin) )
-              or croak("Couldn't dup stdin filehandle to STDIN: '$!'");
-        }
-        else {
-
-            my $stdin = Symbol::qualify_to_ref('STDIN');
-
-            if ( $self->should_restore ) {
-
-                $self->{restore}->{stdin}     = *$stdin;
-                $self->{restore}->{stdin_ref} = \*$stdin;
-            }
-
-            *$stdin = $self->stdin;
-        }
-
-        binmode( $self->stdin );
-        binmode( STDIN );
+        sysseek( $self->stdin, 0, SEEK_SET )
+          or croak("Can't seek stdin handle: $!");
     }
 
-    if ( $self->has_stdout ) {
+    open( $self->{restore}->{stdin}, '<&', STDIN->fileno )
+      or croak("Can't dup stdin: $!");
 
-        if ( $self->should_dup ) {
+    open( STDIN, '<&=', $self->stdin->fileno )
+      or croak("Can't open stdin: $!");
 
-            if ( $self->should_restore ) {
+    binmode( STDIN );
 
-                open( my $stdout, '>&STDOUT' )
-                  or croak("Couldn't dup STDOUT: '$!'");
+    if ( $self->stdout ) {
 
-                $self->{restore}->{stdout} = $stdout;
-            }
+        open( $self->{restore}->{stdout}, '>&', STDOUT->fileno )
+          or croak("Can't dup stdout: $!");
 
-            open( STDOUT, '>&' . fileno($self->stdout) )
-              or croak("Couldn't dup stdout filehandle to STDOUT: '$!'");
-        }
-        else {
+        open( STDOUT, '>&=', $self->stdout->fileno )
+          or croak("Can't open stdout: $!");
 
-            my $stdout = Symbol::qualify_to_ref('STDOUT');
-
-            if ( $self->should_restore ) {
-
-                $self->{restore}->{stdout}     = *$stdout;
-                $self->{restore}->{stdout_ref} = \*$stdout;
-            }
-
-            *$stdout = $self->stdout;
-        }
-
         binmode( $self->stdout );
         binmode( STDOUT);
     }
 
-    if ( $self->has_stderr ) {
+    if ( $self->stderr ) {
 
-        if ( $self->should_dup ) {
+        open( $self->{restore}->{stderr}, '>&', STDERR->fileno )
+          or croak("Can't dup stderr: $!");
 
-            if ( $self->should_restore ) {
+        open( STDERR, '>&=', $self->stderr->fileno )
+          or croak("Can't open stderr: $!");
 
-                open( my $stderr, '>&STDERR' )
-                  or croak("Couldn't dup STDERR: '$!'");
-
-                $self->{restore}->{stderr} = $stderr;
-            }
-
-            open( STDERR, '>&' . fileno($self->stderr) )
-              or croak("Couldn't dup stdout filehandle to STDOUT: '$!'");
-        }
-        else {
-
-            my $stderr = Symbol::qualify_to_ref('STDERR');
-
-            if ( $self->should_restore ) {
-
-                $self->{restore}->{stderr}     = *$stderr;
-                $self->{restore}->{stderr_ref} = \*$stderr;
-            }
-
-            *$stderr = $self->stderr;
-        }
-
         binmode( $self->stderr );
         binmode( STDERR );
     }
 
     {
         no warnings 'uninitialized';
-
-        if ( $self->should_restore ) {
-            $self->{restore}->{environment} = { %ENV };
-        }
-
-        %ENV = %{ $self->environment };
+        %ENV = %{ $self->enviroment };
     }
 
     if ( $INC{'CGI.pm'} ) {
         CGI::initialize_globals();
     }
 
-    $self->is_setup(1);
+    $self->{setuped}++;
 
     return $self;
 }
 
-sub setup_content {
-    my $self  = shift;
-    my $stdin = shift || $self->stdin;
+sub response {
+    my ( $self, $callback ) = @_;
 
-    my $content = $self->request->content_ref;
+    return undef unless $self->stdout;
 
-    if ( ref($content) eq 'SCALAR' ) {
+    seek( $self->stdout, 0, SEEK_SET )
+      or croak("Can't seek stdout handle: $!");
 
-        if ( defined($$content) && length($$content) ) {
-
-            print( { $stdin } $$content )
-              or croak("Couldn't write request content SCALAR to stdin filehandle: '$!'");
-
-            if ( $self->should_rewind ) {
-
-                seek( $stdin, 0, SEEK_SET )
-                  or croak("Couldn't rewind stdin filehandle: '$!'");
-            }
-        }
+    my $headers;
+    while ( my $line = $self->stdout->getline ) {
+        $headers .= $line;
+        last if $headers =~ /\x0d?\x0a\x0d?\x0a$/;
     }
-    elsif ( ref($content) eq 'CODE' ) {
+    
+    unless ( defined $headers ) {
+        $headers = "HTTP/1.1 500 Internal Server Error\x0d\x0a";
+    }
 
-        while () {
-
-            my $chunk = &$content();
-
-            if ( defined($chunk) && length($chunk) ) {
-
-                print( { $stdin } $chunk )
-                  or croak("Couldn't write request content callback to stdin filehandle: '$!'");
-            }
-            else {
-                last;
-            }
-        }
-
-        if ( $self->should_rewind ) {
-
-            seek( $stdin, 0, SEEK_SET )
-              or croak("Couldn't rewind stdin filehandle: '$!'");
-        }
+    unless ( $headers =~ /^HTTP/ ) {
+        $headers = "HTTP/1.1 200 OK\x0d\x0a" . $headers;
     }
-    else {
-        croak("Couldn't write request content to stdin filehandle: 'Unknown request content $content'");
-    }
-}
 
-sub response {
-    my $self   = shift;
-    my %params = ( headers_only => 0, sync => 0, @_ );
+    my $response = HTTP::Response->parse($headers);
+    $response->date( time() ) unless $response->date;
 
-    return undef unless $self->has_stdout;
+    my $message = $response->message;
+    my $status  = $response->header('Status');
 
-    if ( $self->should_rewind ) {
-
-        seek( $self->stdout, 0, SEEK_SET )
-          or croak("Couldn't rewind stdout filehandle: '$!'");
+    if ( $message && $message =~ /^(.+)\x0d$/ ) {
+        $response->message($1);
     }
 
-    my $message  = undef;
-    my $response = HTTP::Response->new( 200, 'OK' );
-       $response->protocol('HTTP/1.1');
+    if ( $status && $status =~ /^(\d\d\d)\s?(.+)?$/ ) {
 
-    while ( my $line = readline($self->stdout) ) {
+        my $code    = $1;
+        my $message = $2 || HTTP::Status::status_message($code);
 
-        if ( !$message && $line =~ /^\x0d?\x0a$/ ) {
-            next;
-        }
-        else {
-            $message .= $line;
-        }
-
-        last if $message =~ /\x0d?\x0a\x0d?\x0a$/;
+        $response->code($code);
+        $response->message($message);
     }
+    
+    my $length = ( stat( $self->stdout ) )[7] - tell( $self->stdout );
 
-    if ( !$message ) {
-        $response->code(500);
-        $response->message('Internal Server Error');
-        $response->date( time() );
+    if ( $response->code == 500 && !$length ) {
+
         $response->content( $response->error_as_HTML );
         $response->content_type('text/html');
-        $response->content_length( length $response->content );
 
         return $response;
     }
 
-    if ( $message =~ s/^($HTTP_Version)[\x09\x20]+(\d\d\d)[\x09\x20]+([\x20-\xFF]*)\x0D?\x0A//o ) {
-        $response->protocol($1);
-        $response->code($2);
-        $response->message($3);
-    }
+    if ($callback) {
 
-    $message =~ s/\x0D?\x0A[\x09\x20]+/\x20/gs;
+        my $handle = $self->stdout;
 
-    foreach ( split /\x0D?\x0A/, $message ) {
+        $response->content( sub {
 
-        s/[\x09\x20]*$//;
+            if ( $handle->read( my $buffer, 4096 ) ) {
+                return $buffer;
+            }
 
-        if ( /^($HTTP_Token+)[\x09\x20]*:[\x09\x20]*([\x20-\xFF]+)$/o ) {
-            $response->headers->push_header( $1 => $2 );
-        }
-        else {
-            # XXX what should we do on bad headers?
-        }
+            return undef;
+        });
     }
+    else {
 
-    my $status = $response->header('Status');
+        my $length = 0;
 
-    if ( $status && $status =~ /^(\d\d\d)[\x09\x20]+([\x20-\xFF]+)$/ ) {
-        $response->code($1);
-        $response->message($2);
-    }
-
-    if ( !$response->date ) {
-        $response->date(time());
-    }
-
-    if ( $params{headers_only} ) {
-
-        if ( $params{sync} ) {
-
-            my $position = tell( $self->stdout )
-              or croak("Couldn't get file position from stdout filehandle: '$!'");
-
-            sysseek( $self->stdout, $position, SEEK_SET )
-              or croak("Couldn't seek stdout filehandle: '$!'");
+        while ( $self->stdout->read( my $buffer, 4096 ) ) {
+            $length += length($buffer);
+            $response->add_content($buffer);
         }
 
-        return $response;
-    }
-
-    my $content        = undef;
-    my $content_length = 0;
-
-    while () {
-
-        my $r = read( $self->stdout, $content, 65536, $content_length );
-
-        if ( defined $r ) {
-
-            if ( $r == 0 ) {
-                last;
-            }
-            else {
-                $content_length += $r;
-            }
+        if ( $length && !$response->content_length ) {
+            $response->content_length($length);
         }
-        else {
-            croak("Couldn't read response content from stdin filehandle: '$!'");
-        }
     }
 
-    if ( $content_length ) {
-
-        $response->content_ref(\$content);
-
-        if ( !$response->content_length ) {
-            $response->content_length($content_length);
-        }
-    }
-
     return $response;
 }
 
 sub restore {
     my $self = shift;
 
-    if ( !$self->should_restore ) {
-        croak(   'An attempt was made to restore environment variables and '
-               . 'standard filehandles which has not been saved.' );
-    }
-
-    if ( !$self->is_setup ) {
-        croak(   'An attempt was made to restore environment variables and '
-               . 'standard filehandles which has not been setup.' );
-    }
-
-    if ( $self->is_restored ) {
-        croak(   'An attempt was made to restore environment variables and '
-               . 'standard filehandles which has already been restored.' );
-    }
-
     {
         no warnings 'uninitialized';
-        %ENV = %{ $self->{restore}->{environment} };
+        %ENV = %{ $self->{restore}->{enviroment} };
     }
 
-    if ( $self->has_stdin ) {
+    open( STDIN, '<&', $self->{restore}->{stdin} )
+      or croak("Can't restore stdin: $!");
 
-        my $stdin = $self->{restore}->{stdin};
+    sysseek( $self->stdin, 0, SEEK_SET )
+      or croak("Can't seek stdin: $!");
 
-        if ( $self->should_dup ) {
+    if ( $self->{restore}->{stdout} ) {
 
-            STDIN->fdopen( fileno($stdin), '<' )
-              or croak("Couldn't restore STDIN: '$!'");
-        }
-        else {
+        STDOUT->flush
+          or croak("Can't flush stdout: $!");
 
-            my $stdin_ref = $self->{restore}->{stdin_ref};
-              *$stdin_ref = $stdin;
-        }
+        open( STDOUT, '>&', $self->{restore}->{stdout} )
+          or croak("Can't restore stdout: $!");
 
-        if ( $self->should_rewind ) {
-
-            seek( $self->stdin, 0, SEEK_SET )
-              or croak("Couldn't rewind stdin filehandle: '$!'");
-        }
+        sysseek( $self->stdout, 0, SEEK_SET )
+          or croak("Can't seek stdout: $!");
     }
 
-    if ( $self->has_stdout ) {
+    if ( $self->{restore}->{stderr} ) {
 
-        my $stdout = $self->{restore}->{stdout};
+        STDERR->flush
+          or croak("Can't flush stderr: $!");
 
-        if ( $self->should_dup ) {
+        open( STDERR, '>&', $self->{restore}->{stderr} )
+          or croak("Can't restore stderr: $!");
 
-            STDOUT->flush
-              or croak("Couldn't flush STDOUT: '$!'");
-
-            STDOUT->fdopen( fileno($stdout), '>' )
-              or croak("Couldn't restore STDOUT: '$!'");
-        }
-        else {
-
-            my $stdout_ref = $self->{restore}->{stdout_ref};
-              *$stdout_ref = $stdout;
-        }
-
-        if ( $self->should_rewind ) {
-
-            seek( $self->stdout, 0, SEEK_SET )
-              or croak("Couldn't rewind stdout filehandle: '$!'");
-        }
+        sysseek( $self->stderr, 0, SEEK_SET )
+          or croak("Can't seek stderr: $!");
     }
 
-    if ( $self->has_stderr ) {
+    $self->{restored}++;
 
-        my $stderr = $self->{restore}->{stderr};
-
-        if ( $self->should_dup ) {
-
-            STDERR->flush
-              or croak("Couldn't flush STDERR: '$!'");
-
-            STDERR->fdopen( fileno($stderr), '>' )
-              or croak("Couldn't restore STDERR: '$!'");
-        }
-        else {
-
-            my $stderr_ref = $self->{restore}->{stderr_ref};
-              *$stderr_ref = $stderr;
-        }
-
-        if ( $self->should_rewind ) {
-
-            seek( $self->stderr, 0, SEEK_SET )
-              or croak("Couldn't rewind stderr filehandle: '$!'");
-        }
-    }
-
-    $self->{restore} = {};
-
-    $self->is_restored(1);
-
     return $self;
 }
 
 sub DESTROY {
     my $self = shift;
-
-    if ( $self->should_restore && $self->is_setup && !$self->is_restored ) {
-        $self->restore;
-    }
+    $self->restore if $self->{setuped} && !$self->{restored};
 }
 
 1;
@@ -606,204 +273,87 @@
 
 =head1 NAME
 
-HTTP::Request::AsCGI - Setup a Common Gateway Interface environment from a HTTP::Request
+HTTP::Request::AsCGI - Setup a CGI enviroment from a HTTP::Request
 
 =head1 SYNOPSIS
 
     use CGI;
     use HTTP::Request;
     use HTTP::Request::AsCGI;
-
+    
     my $request = HTTP::Request->new( GET => 'http://www.host.com/' );
     my $stdout;
-
+    
     {
         my $c = HTTP::Request::AsCGI->new($request)->setup;
         my $q = CGI->new;
-
+        
         print $q->header,
               $q->start_html('Hello World'),
               $q->h1('Hello World'),
               $q->end_html;
-
+        
         $stdout = $c->stdout;
-
-        # environment and descriptors is automatically restored
+        
+        # enviroment and descriptors will automatically be restored 
         # when $c is destructed.
     }
-
+    
     while ( my $line = $stdout->getline ) {
         print $line;
     }
-
+    
 =head1 DESCRIPTION
 
-Provides a convinient way of setting up an CGI environment from a HTTP::Request.
+Provides a convinient way of setting up an CGI enviroment from a HTTP::Request.
 
 =head1 METHODS
 
-=over 4
+=over 4 
 
-=item * new
+=item new ( $request [, key => value ] )
 
-Constructor, this method takes a hash of parameters. The following parameters are
-valid:
+Contructor, first argument must be a instance of HTTP::Request
+followed by optional pairs of environment key and value.
 
-=over 8
+=item enviroment
 
-=item * request
+Returns a hashref containing the environment that will be used in setup. 
+Changing the hashref after setup has been called will have no effect.
 
-    request => HTTP::Request->new( GET => 'http://www.host.com/' )
+=item setup
 
-=item * stdin
+Setups the environment and descriptors.
 
-A filehandle to be used as standard input, defaults to a temporary filehandle.
-If C<stdin> is C<undef>, standard input will be left as is.
+=item restore
 
-    stdin => IO::File->new_tmpfile
-    stdin => IO::String->new
-    stdin => $fh
-    stdin => undef
+Restores the enviroment and descriptors. Can only be called after setup.
 
-=item * stdout
+=item request
 
-A filehandle to be used as standard output, defaults to a temporary filehandle.
-If C<stdout> is C<undef>, standard output will be left as is.
+Returns the request given to constructor.
 
-    stdout => IO::File->new_tmpfile
-    stdout => IO::String->new
-    stdout => $fh
-    stdout => undef
+=item response
 
-=item * stderr
+Returns a HTTP::Response. Can only be called after restore.
 
-A filehandle to be used as standard error, defaults to C<undef>. If C<stderr> is
-C<undef>, standard error will be left as is.
+=item stdin
 
-    stderr => IO::File->new_tmpfile
-    stderr => IO::String->new
-    stderr => $fh
-    stderr => undef
+Accessor for handle that will be used for STDIN, must be a real seekable
+handle with an file descriptor. Defaults to a tempoary IO::File instance.
 
-=item * environment
+=item stdout
 
-A C<HASH> of additional environment variables to be used in CGI.
-C<HTTP::Request::AsCGI> doesn't autmatically merge C<%ENV>, it has to be
-explicitly given if that is desired. Environment variables given in this
-C<HASH> isn't overridden by C<HTTP::Request::AsCGI>.
+Accessor for handle that will be used for STDOUT, must be a real seekable
+handle with an file descriptor. Defaults to a tempoary IO::File instance.
 
-    environment => \%ENV
-    environment => { PATH => '/bin:/usr/bin', SERVER_SOFTWARE => 'Apache/1.3' }
+=item stderr
 
-Following standard meta-variables (in addition to protocol-specific) is setup:
+Accessor for handle that will be used for STDERR, must be a real seekable
+handle with an file descriptor.
 
-    AUTH_TYPE
-    CONTENT_LENGTH
-    CONTENT_TYPE
-    GATEWAY_INTERFACE
-    PATH_INFO
-    SCRIPT_NAME
-    SERVER_NAME
-    SERVER_PORT
-    SERVER_PROTOCOL
-    SERVER_SOFTWARE
-    REMOTE_ADDR
-    REMOTE_HOST
-    REMOTE_USER
-    REQUEST_METHOD
-    QUERY_STRING
-
-Following non-standard but common meta-variables is setup:
-
-    HTTPS
-    REMOTE_PORT
-    REQUEST_URI
-
-Following meta-variables is B<not> setup but B<must> be provided in CGI:
-
-    PATH_TRANSLATED
-
-Following meta-variables is B<not> setup but common in CGI:
-
-    DOCUMENT_ROOT
-    SCRIPT_FILENAME
-    SERVER_ROOT
-
-=item * dup
-
-Boolean to indicate whether to C<dup> standard filehandle or to assign the
-typeglob representing the standard filehandle. Defaults to C<true>.
-
-    dup => 0
-    dup => 1
-
-=item * restore
-
-Boolean to indicate whether or not to restore environment variables and standard
-filehandles. Defaults to C<true>.
-
-    restore => 0
-    restore => 1
-
-If C<true> standard filehandles and environment variables will be saved duiring
-C<setup> for later use in C<restore>.
-
-=item * rewind
-
-Boolean to indicate whether or not to rewind standard filehandles. Defaults
-to C<true>.
-
-    rewind => 0
-    rewind => 1
-
-=item * content
-
-Boolean to indicate whether or not to request content should be written to
-C<stdin> filehandle when C<setup> is invoked. Defaults to C<true>.
-
-    content => 0
-    content => 1
-
 =back
 
-=item * setup
-
-Attempts to setup standard filehandles and environment variables.
-
-=item * restore
-
-Attempts to restore standard filehandles and environment variables.
-
-=item * response
-
-Attempts to parse C<stdout> filehandle into a L<HTTP::Response>.
-
-=item * request
-
-Accessor for L<HTTP::Request> that was given to constructor.
-
-=item * environment
-
-Accessor for environment variables to be used in C<setup>.
-
-=item * stdin
-
-Accessor/Mutator for standard input filehandle.
-
-=item * stdout
-
-Accessor/Mutator for standard output filehandle.
-
-=item * stderr
-
-Accessor/Mutator for standard error filehandle.
-
-=back
-
-=head1 DEPRECATED
-
-XXX Constructor
-
 =head1 SEE ALSO
 
 =over 4
@@ -826,7 +376,7 @@
 
 =head1 LICENSE
 
-This library is free software. You can redistribute it and/or modify
+This library is free software. You can redistribute it and/or modify 
 it under the same terms as perl itself.
 
 =cut

Modified: HTTP-Request-AsCGI/trunk/t/01use.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/01use.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/01use.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,6 +1,6 @@
 #!perl
 
-use Test::More tests => 1;
+use Test::More 'no_plan';
 
 use strict;
 use warnings;

Deleted: HTTP-Request-AsCGI/trunk/t/02pod.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/02pod.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/02pod.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,7 +0,0 @@
-use Test::More;
-
-eval "use Test::Pod 1.14";
-plan skip_all => 'Test::Pod 1.14 required' if $@;
-plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-
-all_pod_files_ok();

Modified: HTTP-Request-AsCGI/trunk/t/04io.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/04io.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/04io.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -14,11 +14,8 @@
 $r->content_length(5);
 $r->content_type('text/plain');
 
-my $c = HTTP::Request::AsCGI->new(
-    request => $r,
-    stderr  => IO::File->new_tmpfile
-);
-
+my $c = HTTP::Request::AsCGI->new($r);
+$c->stderr(IO::File->new_tmpfile);
 $c->setup;
 
 print STDOUT 'STDOUT';

Deleted: HTTP-Request-AsCGI/trunk/t/04ioscalar.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/04ioscalar.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/04ioscalar.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,47 +0,0 @@
-#!perl
-
-use Test::More tests => 3;
-
-{
-    eval "use PerlIO::scalar";
-    plan skip_all => 'PerlIO::scalar required' if $@;
-}
-
-use strict;
-use warnings;
-
-use HTTP::Request;
-use HTTP::Request::AsCGI;
-
-my $r = HTTP::Request->new( POST => 'http://www.host.com/');
-$r->content('STDIN');
-$r->content_length(5);
-$r->content_type('text/plain');
-
-open( my $stdin, ' +<', \( my $stdin_scalar ) )
-  or die qq/Couldn't open a new PerlIO::scalar/;
-
-open( my $stdout, '+>', \( my $stdout_scalar ) )
-  or die qq/Couldn't open a new PerlIO::scalar/;
-
-open( my $stderr, '+>', \( my $stderr_scalar ) )
-  or die qq/Couldn't open a new PerlIO::scalar/;
-
-my $c = HTTP::Request::AsCGI->new(
-    request => $r,
-    dup     => 0,
-    stdin   => $stdin,
-    stdout  => $stdout,
-    stderr  => $stderr
-);
-
-$c->setup;
-
-print STDOUT 'STDOUT';
-print STDERR 'STDERR';
-
-$c->restore;
-
-is( $c->stdin->getline,  'STDIN',  'STDIN' );
-is( $c->stdout->getline, 'STDOUT', 'STDOUT' );
-is( $c->stderr->getline, 'STDERR', 'STDERR' );

Deleted: HTTP-Request-AsCGI/trunk/t/04iostring.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/04iostring.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/04iostring.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,38 +0,0 @@
-#!perl
-
-use Test::More tests => 3;
-
-{
-    eval "use IO::String 1.07";
-    plan skip_all => 'IO::String 1.07 required' if $@;
-}
-
-use strict;
-use warnings;
-
-use HTTP::Request;
-use HTTP::Request::AsCGI;
-
-my $r = HTTP::Request->new( POST => 'http://www.host.com/');
-$r->content('STDIN');
-$r->content_length(5);
-$r->content_type('text/plain');
-
-my $c = HTTP::Request::AsCGI->new(
-    request => $r,
-    dup     => 0,
-    stdin   => IO::String->new,
-    stdout  => IO::String->new,
-    stderr  => IO::String->new
-);
-
-$c->setup;
-
-print STDOUT 'STDOUT';
-print STDERR 'STDERR';
-
-$c->restore;
-
-is( $c->stdin->getline,  'STDIN',  'STDIN' );
-is( $c->stdout->getline, 'STDOUT', 'STDOUT' );
-is( $c->stderr->getline, 'STDERR', 'STDERR' );

Modified: HTTP-Request-AsCGI/trunk/t/05env.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/05env.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/05env.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,6 +1,6 @@
 #!perl
 
-use Test::More tests => 12;
+use Test::More tests => 10;
 
 use strict;
 use warnings;
@@ -9,14 +9,10 @@
 use HTTP::Request::AsCGI;
 
 my $r = HTTP::Request->new( GET => 'http://www.host.com/cgi-bin/script.cgi/my/path/?a=1&b=2', [ 'X-Test' => 'Test' ] );
-   $r->authorization_basic( 'chansen', 'xxx' );
+my %e = ( SCRIPT_NAME => '/cgi-bin/script.cgi' );
+my $c = HTTP::Request::AsCGI->new( $r, %e );
+$c->stdout(undef);
 
-my $c = HTTP::Request::AsCGI->new( 
-    environment => { SCRIPT_NAME => '/cgi-bin/script.cgi' },
-    request     => $r,
-    stdout      => undef
-);
-
 $c->setup;
 
 is( $ENV{GATEWAY_INTERFACE}, 'CGI/1.1', 'GATEWAY_INTERFACE' );
@@ -24,8 +20,6 @@
 is( $ENV{HTTP_X_TEST}, 'Test', 'HTTP_X_TEST' );
 is( $ENV{PATH_INFO}, '/my/path/', 'PATH_INFO' );
 is( $ENV{QUERY_STRING}, 'a=1&b=2', 'QUERY_STRING' );
-is( $ENV{AUTH_TYPE}, 'Basic', 'AUTH_TYPE' );
-is( $ENV{REMOTE_USER}, 'chansen', 'REMOTE_USER' );
 is( $ENV{SCRIPT_NAME}, '/cgi-bin/script.cgi', 'SCRIPT_NAME' );
 is( $ENV{REQUEST_METHOD}, 'GET', 'REQUEST_METHOD' );
 is( $ENV{SERVER_NAME}, 'www.host.com', 'SERVER_NAME' );

Modified: HTTP-Request-AsCGI/trunk/t/06response.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/06response.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/06response.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -13,7 +13,7 @@
 
 {
     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;
     

Modified: HTTP-Request-AsCGI/trunk/t/07forking.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/07forking.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/07forking.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -10,7 +10,7 @@
 use Test::More;
 
 unless ( $Config{d_fork} ) {
-    plan skip_all => 'This test requires a platform that supports fork()';
+    plan skip_all => 'This test requires a plattform that supports fork()';
 }
 
 plan tests => 8;
@@ -19,7 +19,7 @@
 
 {
     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);
 
     my $kid = fork();
 

Modified: HTTP-Request-AsCGI/trunk/t/08error.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/08error.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/08error.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -13,7 +13,7 @@
 
 {
     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;
 
@@ -29,10 +29,10 @@
 
 {
     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: 500 Borked\n";
     print "\n";

Deleted: HTTP-Request-AsCGI/trunk/t/deprecated/04io.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/deprecated/04io.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/deprecated/04io.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,28 +0,0 @@
-#!perl
-
-use Test::More tests => 3;
-
-use strict;
-use warnings;
-
-use IO::File;
-use HTTP::Request;
-use HTTP::Request::AsCGI;
-
-my $r = HTTP::Request->new( POST => 'http://www.host.com/');
-$r->content('STDIN');
-$r->content_length(5);
-$r->content_type('text/plain');
-
-my $c = HTTP::Request::AsCGI->new($r);
-$c->stderr(IO::File->new_tmpfile);
-$c->setup;
-
-print STDOUT 'STDOUT';
-print STDERR 'STDERR';
-
-$c->restore;
-
-is( $c->stdin->getline,  'STDIN',  'STDIN' );
-is( $c->stdout->getline, 'STDOUT', 'STDOUT' );
-is( $c->stderr->getline, 'STDERR', 'STDERR' );

Deleted: HTTP-Request-AsCGI/trunk/t/deprecated/05env.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/deprecated/05env.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/deprecated/05env.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,33 +0,0 @@
-#!perl
-
-use Test::More tests => 12;
-
-use strict;
-use warnings;
-
-use HTTP::Request;
-use HTTP::Request::AsCGI;
-
-my $r = HTTP::Request->new( GET => 'http://www.host.com/cgi-bin/script.cgi/my/path/?a=1&b=2', [ 'X-Test' => 'Test' ] );
-   $r->authorization_basic( 'chansen', 'xxx' );
-my %e = ( SCRIPT_NAME => '/cgi-bin/script.cgi' );
-my $c = HTTP::Request::AsCGI->new( $r, %e );
-
-$c->stdout(undef);
-$c->setup;
-
-is( $ENV{GATEWAY_INTERFACE}, 'CGI/1.1', 'GATEWAY_INTERFACE' );
-is( $ENV{HTTP_HOST}, 'www.host.com:80', 'HTTP_HOST' );
-is( $ENV{HTTP_X_TEST}, 'Test', 'HTTP_X_TEST' );
-is( $ENV{PATH_INFO}, '/my/path/', 'PATH_INFO' );
-is( $ENV{QUERY_STRING}, 'a=1&b=2', 'QUERY_STRING' );
-is( $ENV{AUTH_TYPE}, 'Basic', 'AUTH_TYPE' );
-is( $ENV{REMOTE_USER}, 'chansen', 'REMOTE_USER' );
-is( $ENV{SCRIPT_NAME}, '/cgi-bin/script.cgi', 'SCRIPT_NAME' );
-is( $ENV{REQUEST_METHOD}, 'GET', 'REQUEST_METHOD' );
-is( $ENV{SERVER_NAME}, 'www.host.com', 'SERVER_NAME' );
-is( $ENV{SERVER_PORT}, '80', 'SERVER_PORT' );
-
-$c->restore;
-
-is( $ENV{GATEWAY_INTERFACE}, undef, 'No CGI env after restore' );

Deleted: HTTP-Request-AsCGI/trunk/t/deprecated/06response.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/deprecated/06response.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/deprecated/06response.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,39 +0,0 @@
-#!perl
-
-use Test::More tests => 9;
-
-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;
-    
-    print "Content-Type: text/plain\n";
-    print "Status: 200 Yay\n";
-    print "Date: Thu, 19 Jan 2006 14:08:18 GMT\n";
-    print "X-Field: 1\n";
-    print "X-Field: 2\n";
-    print "\n";
-    print "Hello!";
-
-    $response = $c->restore->response;
-}
-
-isa_ok( $response, 'HTTP::Response' );
-is( $response->code, 200, 'Response Code' );
-is( $response->message, 'Yay', 'Response Message' );
-is( $response->protocol, 'HTTP/1.1', 'Response Protocol' );
-is( $response->content, 'Hello!', 'Response Content' );
-is( $response->content_length, 6, 'Response Content-Length' );
-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' );

Deleted: HTTP-Request-AsCGI/trunk/t/deprecated/07forking.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/deprecated/07forking.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/deprecated/07forking.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,59 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use Config;
-use IO::File;
-use HTTP::Request;
-use HTTP::Request::AsCGI;
-use Test::More;
-
-unless ( $Config{d_fork} ) {
-    plan skip_all => 'This test requires a platform that supports fork()';
-}
-
-plan tests => 8;
-
-my $response;
-
-{
-    my $r = HTTP::Request->new( GET => 'http://www.host.com/' );
-    my $c = HTTP::Request::AsCGI->new($r);
-
-    my $kid = fork();
-
-    unless ( defined $kid ) {
-        die("Can't fork() kid: $!");
-    }
-
-    unless ( $kid ) {
-
-        $c->setup;
-
-        print "HTTP/1.0 200 OK\n";
-        print "Content-Type: text/plain\n";
-        print "Status: 200\n";
-        print "X-Field: 1\n";
-        print "X-Field: 2\n";
-        print "\n";
-        print "Hello!";
-
-        $c->restore;
-
-        exit(0);
-    }
-
-    waitpid( $kid, 0 );
-
-    $response = $c->response;
-}
-
-isa_ok( $response, 'HTTP::Response' );
-is( $response->code, 200, 'Response Code' );
-is( $response->message, 'OK', 'Response Message' );
-is( $response->protocol, 'HTTP/1.0', 'Response Protocol' );
-is( $response->content, 'Hello!', 'Response Content' );
-is( $response->content_length, 6, 'Response Content-Length' );
-is( $response->content_type, 'text/plain', 'Response Content-Type' );
-is_deeply( [ $response->header('X-Field') ], [ 1, 2 ], 'Response Header X-Field' );

Deleted: HTTP-Request-AsCGI/trunk/t/deprecated/08error.t
===================================================================
--- HTTP-Request-AsCGI/trunk/t/deprecated/08error.t	2009-04-26 20:56:27 UTC (rev 9863)
+++ HTTP-Request-AsCGI/trunk/t/deprecated/08error.t	2009-04-26 23:01:45 UTC (rev 9864)
@@ -1,49 +0,0 @@
-#!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' );




More information about the Catalyst-commits mailing list