vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r16101: use LJ::Request instead of Apache(->requ...

Committer: vsukhanov
use LJ::Request instead of Apache(->request).
U   branches/modernize2/cgi-bin/Apache/DebateSuicide.pm
U   branches/modernize2/cgi-bin/Apache/LiveJournal/Interface/ElsewhereInfo.pm
U   branches/modernize2/cgi-bin/Apache/LiveJournal/PalImg.pm
U   branches/modernize2/cgi-bin/Apache/LiveJournal.pm
Modified: branches/modernize2/cgi-bin/Apache/DebateSuicide.pm
===================================================================
--- branches/modernize2/cgi-bin/Apache/DebateSuicide.pm	2010-01-19 08:22:21 UTC (rev 16100)
+++ branches/modernize2/cgi-bin/Apache/DebateSuicide.pm	2010-01-19 08:23:39 UTC (rev 16101)
@@ -16,8 +16,8 @@
 # oh btw, this is totally linux-specific.  gtop didn't work, so so much for portability.
 sub handler
 {
-    my $r = shift;
-    return OK if $r->main;
+    #my $r = shift;
+    return OK if LJ::Request->main;
     return OK unless $LJ::SUICIDE && LJ::ModuleCheck->have("GTop");
 
     my $meminfo;
@@ -77,17 +77,17 @@
     if (grep { $$ == $_ } @pids[0,1]) {
         my $my_use_k = $stats{$$}[0] >> 10;
         if ($LJ::DEBUG{'suicide'}) {
-            $r->log_error("Suicide [$$]: system memory free = ${memfree}k; " .
+            LJ::Request->log_error("Suicide [$$]: system memory free = ${memfree}k; " .
                           "i'm big, using ${my_use_k}k");
         }
 
         # we should have logged by here, but be paranoid in any case
-        Apache::LiveJournal::db_logger($r) unless $r->pnotes('did_lj_logging');
+        Apache::LiveJournal::db_logger() unless LJ::Request->pnotes('did_lj_logging');
 
         # This is supposed to set MaxChildRequests to 1, then clear the
         # KeepAlive flag so that Apache will terminate after this request,
         # but it doesn't work.  We'll call it here just in case.
-        $r->child_terminate;
+        LJ::Request->child_terminate;
 
         # We should call Apache::exit(Apache::Constants::DONE) here because
         # it makes sure that the child shuts down cleanly after fulfilling

Modified: branches/modernize2/cgi-bin/Apache/LiveJournal/Interface/ElsewhereInfo.pm
===================================================================
--- branches/modernize2/cgi-bin/Apache/LiveJournal/Interface/ElsewhereInfo.pm	2010-01-19 08:22:21 UTC (rev 16100)
+++ branches/modernize2/cgi-bin/Apache/LiveJournal/Interface/ElsewhereInfo.pm	2010-01-19 08:23:39 UTC (rev 16101)
@@ -13,7 +13,6 @@
 sub load { 1 }
 
 sub should_handle {
-    my $r = shift;
 
     # FIXME: trust specific consumers of this data?
     return $LJ::IS_DEV_SERVER ? 1 : 0;
@@ -24,27 +23,27 @@
 # prints the response.
 sub handle {
     shift if $_[0] eq __PACKAGE__;
-    my $r = shift;
+    #my $r = shift;
 
-    my %args = $r->args;
+    my %args = LJ::Request->args;
 
     # should we handle this request due according to access rules?
-    unless (should_handle($r)) {
-        return respond($r, 403, "Forbidden");
+    unless (should_handle()) {
+        return respond(403, "Forbidden");
     }
 
     # find what node_u we're dealing with
     my $u;
     if (my $id = $args{id}) {
         $u = LJ::load_userid($id);
-        return respond($r, 404, "Invalid id: $id")
+        return respond(404, "Invalid id: $id")
             unless $u;
     } elsif (my $node = $args{ident}) {
         $u = LJ::load_user($node);
-        return respond($r, 404, "Invalid ident: $node")
+        return respond(404, "Invalid ident: $node")
             unless $u;
     } else {
-        return respond($r, 400, "Must specify 'id' or 'ident'");
+        return respond(400, "Must specify 'id' or 'ident'");
     }
 
     # find what node type we're dealing with
@@ -58,7 +57,7 @@
         $node_type = 'openid';
         $node_ident = $u->url; # should be identity type O
     } else {
-        return respond($r, 403, "Node is neither person, group, nor openid: " . $u->user . " (" . $u->id . ")");
+        return respond(403, "Node is neither person, group, nor openid: " . $u->user . " (" . $u->id . ")");
     }
 
     # response hash to pass to JSON
@@ -86,13 +85,13 @@
         $resp{edges_out} = [ map { $_ } $u->friend_uids   ];
     }
 
-    respond($r, 200, JSON::objToJson(\%resp));
+    respond(200, JSON::objToJson(\%resp));
 
     return OK;
 }
 
 sub respond {
-    my ($r, $status, $body) = @_;
+    my ($status, $body) = @_;
 
     my %msgs = (
                 200 => 'OK',
@@ -102,10 +101,10 @@
                 500 => 'Server Error',
                 );
 
-    $r->status_line(join(" ", grep { length } $status, $msgs{$status}));
-    $r->content_type('text/html');#'application/json');
-    $r->send_http_header();
-    $r->print($body);
+    LJ::Request->status_line(join(" ", grep { length } $status, $msgs{$status}));
+    LJ::Request->content_type('text/html');#'application/json');
+    LJ::Request->send_http_header();
+    LJ::Request->print($body);
 
     return OK;
 };

Modified: branches/modernize2/cgi-bin/Apache/LiveJournal/PalImg.pm
===================================================================
--- branches/modernize2/cgi-bin/Apache/LiveJournal/PalImg.pm	2010-01-19 08:22:21 UTC (rev 16100)
+++ branches/modernize2/cgi-bin/Apache/LiveJournal/PalImg.pm	2010-01-19 08:23:39 UTC (rev 16101)
@@ -16,7 +16,7 @@
 
 sub handler
 {
-    my $r = shift;
+    #my $r = shift;
     my $uri = LJ::Request->uri;
     my ($base, $ext, $extra) = $uri =~ m!^/palimg/(.+)\.(\w+)(.*)$!;
     LJ::Request->notes("codepath" => "img.palimg");

Modified: branches/modernize2/cgi-bin/Apache/LiveJournal.pm
===================================================================
--- branches/modernize2/cgi-bin/Apache/LiveJournal.pm	2010-01-19 08:22:21 UTC (rev 16100)
+++ branches/modernize2/cgi-bin/Apache/LiveJournal.pm	2010-01-19 08:23:39 UTC (rev 16101)
@@ -90,7 +90,7 @@
 sub handler
 {
     my $class = ();
-    my $r     = shift;
+    my $r     = shift; # 
 
     LJ::Request->free();
     LJ::Request->init($r);
@@ -199,7 +199,6 @@
 
 sub totally_down_content
 {
-    #my $r = shift;
     my $uri = LJ::Request->uri;
 
     if ($uri =~ m!^/interface/flat! || $uri =~ m!^/cgi-bin/log\.cg!) {
@@ -229,8 +228,6 @@
 
 sub blocked_bot
 {
-    #my $r = shift;
-
     LJ::Request->status_line("403 Denied");
     LJ::Request->content_type("text/html");
     LJ::Request->send_http_header();
@@ -249,7 +246,6 @@
 
 sub trans
 {
-    #my $r = shift;
     return DECLINED if ! LJ::Request->is_main || LJ::Request->method_number == LJ::Request->M_OPTIONS;  # don't deal with subrequests or OPTIONS
 
     my $uri = LJ::Request->uri;
@@ -971,7 +967,6 @@
 
 sub userpic_trans
 {
-    #my $r = shift;
     return 404 unless LJ::Request->uri =~ m!^/(?:userpic/)?(\d+)/(\d+)$!;
     my ($picid, $userid) = ($1, $2);
 
@@ -1028,7 +1023,6 @@
 
 sub userpic_content
 {
-    #my $r = shift;
     my $file = LJ::Request->filename;
 
     my $picid = $RQ{'picid'};
@@ -1210,8 +1204,6 @@
 
 sub files_handler {
 
-    #my $r = LJ::Request->r;
-
     use LJ::FileStore;
     my $result = LJ::FileStore->get_path_info( path => LJ::Request->uri );
 
@@ -1253,7 +1245,6 @@
 
 sub files_trans
 {
-    #my $r = shift;
     LJ::Request->uri =~ m!^/(\w{1,15})/(\w+)(/\S+)!;
     my ($user, $domain, $rest) = ($1, $2, $3);
 
@@ -1275,7 +1266,6 @@
 
 sub journal_content
 {
-    #my $r = shift;
     my $uri = LJ::Request->uri;
     my %GET = LJ::Request->args;
 
@@ -1543,7 +1533,6 @@
 
 sub customview_content
 {
-    #my $r = shift;
     my %FORM = LJ::Request->args;
 
     my $charset = "utf-8";
@@ -1628,7 +1617,6 @@
 
 sub interface_content
 {
-    #my $r = shift;
     my $args = LJ::Request->args;
 
     if ($RQ{'interface'} eq "xmlrpc") {
@@ -1715,8 +1703,6 @@
 
 sub db_logger
 {
-    #my $r = shift;
-
     LJ::Request->pnotes('did_lj_logging' => 1);
 
     # these are common enough, it's worth doing it here, early, before
@@ -1748,7 +1734,6 @@
 
 sub anti_squatter
 {
-    #my $r = shift;
     LJ::Request->push_handlers(PerlHandler => sub {
         LJ::Request->content_type("text/html");
         LJ::Request->send_http_header();

Tags: livejournal, pm, vadvs
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments