From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH/RFC 5/6] gitweb: Make possible to run under mod_perl without SetupEnv
Date: Thu, 28 Dec 2006 00:49:12 +0100 [thread overview]
Message-ID: <200612280049.13385.jnareb@gmail.com> (raw)
In-Reply-To: <200612272355.31923.jnareb@gmail.com>
Make possible to run gitweb under mod_perl without need to set up CGI
environmental variables (i.e. "PerlOptions -SetupEnv" in mod_perl 2.0,
"PerlSetupEnv Off" in mod_perl 1.0).
Actually ModPerl::Registry / Apache::Registry populates %ENV hash,
without need to actually set environmental variables.
Pass the request variable $r to CGI constructor if CGI.pm module is
new enough (at least CGI version 2.93, and at least 3.11 for mod_perl
2.0).
Replace $ENV{'PATH_INFO'} by $r->path_info() if we use mod_perl.
Replace $ENV{'SERVER_NAME'} by $r->server()->server_hostname() if we
use mod_perl.
Uniquify using of %ENV to $ENV{'NAME'}, while at it.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This patch appears to be unnecessary, at least for now, because
mod_perl Registry populates %ENV hash (and does not need to set
envirionmental variables). Still, it prepares the way for future
running gitweb as mod_perl handler, and not under Registry.
Perhaps the cleanup part of this patch should be put into separate
patch...
gitweb/gitweb.perl | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 9983e9e..2900ae6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -32,11 +32,16 @@ BEGIN {
# use appropriate mod_perl modules (conditional use)
if (MP_GEN == 2) {
require Apache2::RequestRec;
+ require Apache2::ServerRec;
+ require Apache2::Response;
require Apache2::Const;
+ Apache2::RequestRec->import();
+ Apache2::ServerRec->import();
Apache2::Const->import(-compile => qw(:common :http));
} elsif (MP_GEN == 1) {
require Apache;
require Apache::Constants;
+ import Apache;
Apache::Constants->import(qw(:common :http));
}
@@ -48,7 +53,15 @@ BEGIN {
my $r;
$r = shift @_ if MP_GEN;
-our $cgi = new CGI;
+our $cgi;
+if ((MP_GEN == 1 && $CGI::VERSION >= 2.93) ||
+ (MP_GEN == 2 && $CGI::VERSION >= 3.11)) {
+ # CGI.pm is new enough
+ $cgi = new CGI($r);
+} else {
+ $cgi = new CGI;
+}
+
our $version = "++GIT_VERSION++";
our $my_url = $cgi->url();
our $my_uri = $cgi->url(-absolute => 1);
@@ -70,7 +83,8 @@ our $home_link_str = "++GITWEB_HOME_LINK_STR++";
# name of your site or organization to appear in page titles
# replace this with something more descriptive for clearer bookmarks
our $site_name = "++GITWEB_SITENAME++"
- || ($ENV{'SERVER_NAME'} || "Untitled") . " Git";
+ || (($r ? $r->server()->server_hostname() : $ENV{'SERVER_NAME'})
+ || "Untitled") . " Git";
# filename of html text to include at top of each page
our $site_header = "++GITWEB_SITE_HEADER++";
@@ -403,7 +417,7 @@ if (defined $searchtype) {
# now read PATH_INFO and use it as alternative to parameters
sub evaluate_path_info {
return if defined $project;
- my $path_info = $ENV{"PATH_INFO"};
+ my $path_info = $r ? $r->path_info() : $ENV{'PATH_INFO'};
return if !$path_info;
$path_info =~ s,^/+,,;
return if !$path_info;
--
1.4.4.3
next prev parent reply other threads:[~2006-12-28 0:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-27 22:55 [PATCH 0/6] gitweb: Some mod_perl specific support (but not only) Jakub Narebski
2006-12-27 22:57 ` [PATCH 1/6] gitweb: Separate HTTP header output Jakub Narebski
2006-12-28 1:23 ` Junio C Hamano
2006-12-28 1:28 ` Shawn Pearce
2006-12-27 22:59 ` [PATCH 2/6] gitweb: Add mod_perl version string to "generator" meta header Jakub Narebski
2006-12-27 23:00 ` [PATCH 3/6] gitweb: Precompile CGI routines for mod_perl Jakub Narebski
2006-12-27 23:04 ` [PATCH/RFC 4/6] gitweb: Prepare for mod_perl specific support Jakub Narebski
2006-12-27 23:49 ` Jakub Narebski [this message]
2006-12-28 0:06 ` [RFC/PATCH 6/6] gitweb: Make possible to run under mod_perl without ParseHeaders Jakub Narebski
2006-12-28 1:03 ` Robert Fitzsimons
2006-12-28 1:12 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200612280049.13385.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).