[Rt-commit] [svn] r796 - in rt: . branches/rt-3.3/bin branches/rt-3.3/html/REST/2.0 branches/rt-3.3/html/REST/2.0/Error branches/rt-3.3/html/REST/2.0/Search

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Sat May 1 12:07:33 EDT 2004


Author: autrijus
Date: Sat May  1 12:07:33 2004
New Revision: 796

Modified:
   rt/   (props changed)
   rt/branches/rt-3.3/bin/standalone_httpd.in
   rt/branches/rt-3.3/html/REST/2.0/Error/index
   rt/branches/rt-3.3/html/REST/2.0/Search/index
   rt/branches/rt-3.3/html/REST/2.0/dhandler
Log:
 ----------------------------------------------------------------------
 r4349 at not:  autrijus | 2004-05-01T15:36:00.221832Z
 
 * Properly clean up leftover HTTP_* environment variables.
 * Pass authorization header to Mason.
 * Send out correct HTTP status code instead of blindly assuming 200.
 ----------------------------------------------------------------------
 r4350 at not:  autrijus | 2004-05-01T15:59:39.046584Z
 
 * RT::Date->new also takes currentuser.
 ----------------------------------------------------------------------
 r4351 at not:  autrijus | 2004-05-01T16:00:38.530367Z
 
 * Correctly handle nonce disposal.
 * $m->abort is needed for mod_perl2.
 ----------------------------------------------------------------------


Modified: rt/branches/rt-3.3/bin/standalone_httpd.in
==============================================================================
--- rt/branches/rt-3.3/bin/standalone_httpd.in	(original)
+++ rt/branches/rt-3.3/bin/standalone_httpd.in	Sat May  1 12:07:33 2004
@@ -10,7 +10,8 @@
 
 RT::Init();
 
-my $port = 4711;
+my $port = shift || '8080';
+if ( @RT::MasonParameters) {} # Shut up the warnings;
 my $h = &RT::Interface::Web::NewCGIHandler(@RT::MasonParameters);
 
 main_loop($port);
@@ -48,12 +49,11 @@
             chomp( $_ = <STDIN> );
             my ( $method, $request_uri, $proto, undef ) = split;
 
-            $request_uri =~ s#\\#/#g;
+            #$request_uri =~ s#\\#/#g;
             $RT::Logger->info("<- $peername: $_");
             my ( $file, undef, $query_string ) =
               ( $request_uri =~ /([^?]*)(\?(.*))?/ );    # split at ?
-            $file =~
-              s/%([\dA-Fa-f]{2})/chr(hex($1))/eg;  # decode url-escaped entities
+            #$file =~ s/%([\dA-Fa-f]{2})/chr(hex($1))/eg;  # decode url-escaped entities
 
             last if ( $method !~ /^(GET|POST|HEAD)$/ );
 
@@ -106,15 +106,27 @@
 
                         @_);
                     
-        foreach my $var qw(USER_AGENT CONTENT_LENGTH CONTENT_TYPE) {
+        foreach my $var qw(USER_AGENT CONTENT_LENGTH CONTENT_TYPE
+          COOKIE SERVER_PORT SERVER_PROTOCOL SERVER_NAME
+          PATH_INFO REQUEST_URI REQUEST_METHOD REMOTE_ADDR
+          REMOTE_HOST QUERY_STRING SERVER_SOFTWARE) {
             delete $ENV{$var};
-        }
+          }
         while (<STDIN>) {
             s/[\r\l\n\s]+$//;
-            /^User-Agent: (.+)/i      and $ENV{USER_AGENT}     = $1;
-            /^Content-length: (\d+)/i and $ENV{CONTENT_LENGTH} = $1;
-            /^Content-type: (.+)/i    and $ENV{CONTENT_TYPE}   = $1;
-            /^Cookie.?: (.+)/i and $ENV{COOKIE} .= $1 . "; ";
+            if( /^([\w\-]+): (.+)/i) {
+                my $tag = uc($1);
+                $tag =~ s/^COOKIES$/COOKIE/;
+                my $val = $2;
+                $tag =~ s/-/_/g;
+                $tag = "HTTP_".$tag unless (grep /^$tag$/, qw(CONTENT_LENGTH CONTENT_TYPE COOKIE));
+                if ($ENV{$tag}) {
+                $ENV{$tag} .= "; $val";
+                }
+                else {
+                $ENV{$tag} = $val;
+                }
+            } 
             last if (/^$/);
         }
 

Modified: rt/branches/rt-3.3/html/REST/2.0/Error/index
==============================================================================
--- rt/branches/rt-3.3/html/REST/2.0/Error/index	(original)
+++ rt/branches/rt-3.3/html/REST/2.0/Error/index	Sat May  1 12:07:33 2004
@@ -1,6 +1,7 @@
 <%INIT>
 $r->content_type('text/html');
 $r->status($Status);
+$m->abort($Status);
 </%INIT>
 <%ARGS>
 $Status => 500

Modified: rt/branches/rt-3.3/html/REST/2.0/Search/index
==============================================================================
--- rt/branches/rt-3.3/html/REST/2.0/Search/index	(original)
+++ rt/branches/rt-3.3/html/REST/2.0/Search/index	Sat May  1 12:07:33 2004
@@ -46,7 +46,7 @@
 
 my $entries = '';
 
-my $now = RT::Date->new;
+my $now = RT::Date->new($session{CurrentUser});
 $now->SetToNow;
 my $modified = $now->W3CDTF;
 

Modified: rt/branches/rt-3.3/html/REST/2.0/dhandler
==============================================================================
--- rt/branches/rt-3.3/html/REST/2.0/dhandler	(original)
+++ rt/branches/rt-3.3/html/REST/2.0/dhandler	Sat May  1 12:07:33 2004
@@ -40,7 +40,6 @@
 	$v =~ s/"$//;
 	$parts{lc($k)} = $v;
     }
-    $RT::Logger->error(join(',', %parts));
     $parts{lc($_)} = delete $parts{$_} for map "$_", keys %parts;
     return \%parts;
 };
@@ -101,25 +100,23 @@
     $CurrentUser->Load($username) or last;
 
     # check against reused nonces
+    require MIME::Base64;
+    $auth_nonce = MIME::Base64::decode_base64($auth_nonce);
+
     my $nonce_cache;
-    if ($auth_nonce) {
-	require Cache::FileCache;
-	$nonce_cache = Cache::FileCache->new({
-	    namespace => 'RT-Nonces',
-	    default_expires_in => 1728000,
-	    auto_purge_interval => 3600,
-	});
-        $auth_nonce = substr($auth_nonce, 0, 32);
-        last if $nonce_cache->get( $auth_nonce );
-    }
+    require Cache::FileCache;
+    $nonce_cache = Cache::FileCache->new({
+	namespace => 'RT-Nonces',
+	default_expires_in => 1728000,
+	auto_purge_interval => 3600,
+    });
+    $auth_nonce = substr($auth_nonce, 0, 32);
+    (undef($CurrentUser), last) if $nonce_cache->get( $auth_nonce );
 
     # if ($auth_created and abs($auth_created - time) >= 864000) {
     #	last; # system clock differ by more than one day, oops!
     # }
 
-    require MIME::Base64;
-    $auth_nonce = MIME::Base64::decode_base64($auth_nonce);
-
     $CurrentUser->Authenticate(
 	$auth_digest, $auth_created, $auth_nonce, $realm
     ) or (undef($CurrentUser), last);
@@ -129,7 +126,7 @@
 }
 
 if (!$CurrentUser or !$CurrentUser->Id) {
-    $m->comp('Error/index', Status => 401);
+    return $m->comp('Error/index', Status => 401);
 }
 
 $session{CurrentUser} = $CurrentUser;


More information about the Rt-commit mailing list