From: <a_...@us...> - 2006-02-01 20:18:47
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Response In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4756/lib/OpenInteract2/Response Modified Files: Apache.pm Apache2.pm CGI.pm LWP.pm Standalone.pm Log Message: Response classes now store redirect headers and write them at send() instead of writing them instantly Index: Apache.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Response/Apache.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Apache.pm 21 Sep 2005 03:35:23 -0000 1.22 --- Apache.pm 1 Feb 2006 20:18:34 -0000 1.23 *************** *** 97,102 **** $log ||= get_logger( LOG_RESPONSE ); - $self->save_session; - $url ||= $self->return_url; $log->is_info && --- 97,100 ---- Index: Apache2.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Response/Apache2.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Apache2.pm 17 Mar 2005 14:58:05 -0000 1.7 --- Apache2.pm 1 Feb 2006 20:18:34 -0000 1.8 *************** *** 92,97 **** $log ||= get_logger( LOG_RESPONSE ); - $self->save_session; - $url ||= $self->return_url; $log->is_info && --- 92,95 ---- *************** *** 99,103 **** "'Location' header to '$url'" ); $self->status( RC_FOUND ); ! $self->header_out( Location => $url ); return; } --- 97,101 ---- "'Location' header to '$url'" ); $self->status( RC_FOUND ); ! $self->header( Location => $url ); return; } Index: CGI.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Response/CGI.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** CGI.pm 22 Oct 2005 21:53:45 -0000 1.21 --- CGI.pm 1 Feb 2006 20:18:34 -0000 1.22 *************** *** 64,71 **** } ! unless ( $self->is_redirect ) { ! $self->out( $self->generate_cgi_header_fields, "\r\n\r\n" ); ! $self->out( $self->content ); ! } } --- 64,69 ---- } ! $self->out( $self->generate_cgi_header_fields, "\r\n\r\n" ); ! $self->out( $self->content ); } *************** *** 96,101 **** $log ||= get_logger( LOG_RESPONSE ); - $self->save_session; - $url ||= $self->return_url; $log->is_info && --- 94,97 ---- *************** *** 103,111 **** "'Location' header to '$url'" ); $self->status( RC_FOUND ); ! my @header = (); ! push @header, "Status: 302 Moved"; ! push @header, "Location: $url"; ! push @header, $self->_generate_cookie_lines; ! $self->out( join( "\r\n", @header ), "\r\n\r\n" ); } --- 99,103 ---- "'Location' header to '$url'" ); $self->status( RC_FOUND ); ! $self->header( Location => $url ); } Index: LWP.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Response/LWP.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** LWP.pm 17 Mar 2005 14:58:05 -0000 1.22 --- LWP.pm 1 Feb 2006 20:18:34 -0000 1.23 *************** *** 32,40 **** $log->is_info && $log->info( "Sending LWP response" ); ! if ( $self->is_redirect ) { ! $log->is_info ! && $log->info( "Response is redirect, already sent" ); ! return; ! } $self->content_type( 'text/html' ) unless ( $self->content_type ); $self->status( RC_OK ) unless ( $self->status ); --- 32,36 ---- $log->is_info && $log->info( "Sending LWP response" ); ! $self->content_type( 'text/html' ) unless ( $self->content_type ); $self->status( RC_OK ) unless ( $self->status ); *************** *** 49,53 **** $self->lwp_response( HTTP::Response->new( $self->status ) ); } ! if ( my $filename = $self->send_file ) { $self->set_file_info; $self->_set_lwp_headers; --- 45,61 ---- $self->lwp_response( HTTP::Response->new( $self->status ) ); } ! ! if ( $self->is_redirect ) { ! $self->_set_lwp_headers; ! if ( my $client = $self->client ) { ! $client->send_response( $self->lwp_response ); ! $log->is_info && $log->info( "Sent redirect response" ); ! } ! else { ! $log->is_info && ! $log->info( "Set content/headers but did not send content" ); ! } ! } ! elsif ( my $filename = $self->send_file ) { $self->set_file_info; $self->_set_lwp_headers; *************** *** 79,106 **** $log ||= get_logger( LOG_RESPONSE ); - $self->save_session; - $url ||= $self->return_url; $log->is_info && ! $log->info( "Got request for redirect to '$url'" ); - my $lwp_response = $self->lwp_response; - unless ( $lwp_response ) { - $self->lwp_response( HTTP::Response->new( RC_FOUND ) ); - $lwp_response = $self->lwp_response; - } - else { - $lwp_response->code( RC_FOUND ); - } $self->status( RC_FOUND ); ! $lwp_response->header( Location => $url ); ! $log->is_info && ! $log->info( "Set 'Location' header to ", $lwp_response->header( 'Location' ) ); ! $self->_set_lwp_cookies; ! $log->debug( "Getting ready to send response: ", CTX->dump( $lwp_response ) ); ! if ( my $client = $self->client ) { ! $client->send_response( $lwp_response ); ! } ! $log->is_info && $log->info( "Sent redirect ok" ); } --- 87,97 ---- $log ||= get_logger( LOG_RESPONSE ); $url ||= $self->return_url; $log->is_info && ! $log->info( "Assigning redirect status and redirect ", ! "'Location' header to '$url'" ); $self->status( RC_FOUND ); ! $self->header( Location => $url ); } Index: Standalone.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Response/Standalone.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Standalone.pm 17 Mar 2005 14:58:05 -0000 1.15 --- Standalone.pm 1 Feb 2006 20:18:34 -0000 1.16 *************** *** 91,100 **** sub redirect { my ( $self, $url ) = @_; ! $self->save_session; ! my @header = (); ! push @header, "Status: 302 Moved"; ! push @header, "Location: $url"; ! push @header, $self->_generate_cookie_lines; ! $self->out( join( "\r\n", @header ), "\r\n\r\n" ); } --- 91,102 ---- sub redirect { my ( $self, $url ) = @_; ! $log ||= get_logger( LOG_RESPONSE ); ! ! $url ||= $self->return_url; ! $log->is_info && ! $log->info( "Assigning redirect status and redirect ", ! "'Location' header to '$url'" ); ! $self->status( RC_FOUND ); ! $self->header( Location => $url ); } |