[livejournal] r20140: LJSUP-9792 (generalize m.livejournal.com...
Committer: ailyin
LJSUP-9792 (generalize m.livejournal.com's router/controller/response framework)U trunk/cgi-bin/Apache/LiveJournal.pm U trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/Apache/LiveJournal.pm
===================================================================
--- trunk/cgi-bin/Apache/LiveJournal.pm 2011-09-27 09:08:51 UTC (rev 20139)
+++ trunk/cgi-bin/Apache/LiveJournal.pm 2011-09-27 09:38:16 UTC (rev 20140)
@@ -194,6 +194,7 @@
return $status;
}
}
+
LJ::Request->set_handlers(PerlTransHandler => [ \&trans ]);
return LJ::Request::OK;
@@ -335,6 +336,8 @@
my $is_ssl = $LJ::IS_SSL = LJ::run_hook('ssl_check');
$LJ::IS_BOT_USERAGENT = BotCheck->is_bot( LJ::Request->header_in('User-Agent') );
+ LJ::Request->pnotes( 'original_uri' => LJ::Request->uri );
+
# process controller
# if defined
if ( my $controller = LJ::Request->notes('controller') ) {
@@ -401,6 +404,16 @@
LJ::Request->pnotes ('remote' => LJ::get_remote());
if (LJ::Request->status == 404) {
+ if ( LJ::Request->prev
+ && LJ::Request->prev->notes('http_errors_no_bml') )
+ {
+ LJ::Request->handler('perl-script');
+ LJ::Request->set_handlers(
+ 'PerlHandler' => sub { return LJ::Request::OK; }
+ );
+ return LJ::Request::OK;
+ }
+
my $fn = $LJ::PAGE_404 || '404-error.html';
return $bml_handler->("$LJ::HOME/htdocs/" . $fn);
}
@@ -508,11 +521,6 @@
my %GET = LJ::Request->args;
- if ($LJ::IS_DEV_SERVER && $GET{'as'} =~ /^\w{1,15}$/) {
- my $ru = LJ::load_user($GET{'as'});
- LJ::set_remote($ru); # might be undef, to allow for "view as logged out"
- }
-
# anti-squatter checking
if ($LJ::DEBUG{'anti_squatter'} && LJ::Request->method eq "GET") {
my $ref = LJ::Request->header_in("Referer");
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm 2011-09-27 09:08:51 UTC (rev 20139)
+++ trunk/cgi-bin/LJ/User.pm 2011-09-27 09:38:16 UTC (rev 20140)
@@ -10074,6 +10074,15 @@
# can't have a remote user outside of web context
return $no_remote->() unless LJ::Request->is_inited;
+ my $get_as = LJ::Request->get_param('as');
+ if ( $LJ::IS_DEV_SERVER && $get_as =~ /^\w{1,15}$/ ) {
+ my $ru = LJ::load_user($get_as);
+
+ # might be undef, to allow for "view as logged out":
+ LJ::set_remote($ru);
+ return $ru;
+ }
+
my $criterr = $opts->{criterr} || do { my $d; \$d; };
$$criterr = 0;
