- From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 21 Sep 2009 19:12:05 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv1718
Modified Files:
check
Log Message:
Try to acquire auth info from mod_perl if HTTP_AUTHORIZATION is not set.
Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.699
retrieving revision 1.700
diff -u -d -r1.699 -r1.700
--- check 21 Sep 2009 19:08:41 -0000 1.699
+++ check 21 Sep 2009 19:12:03 -0000 1.700
@@ -90,6 +90,9 @@
# Define global variables.
use vars qw($DEBUG $CFG %RSRC $VERSION);
+use constant IS_MODPERL2 =>
+ (exists($ENV{MOD_PERL_API_VERSION}) && $ENV{MOD_PERL_API_VERSION} >= 2);
+
#
# Things inside BEGIN don't happen on every request in persistent environments
# (such as mod_perl); so let's do the globals, eg. read config, here.
@@ -1640,11 +1643,18 @@
$req->header(Accept_Charset => $File->{Opt}->{'Accept-Charset Header'});
}
+ # All Apache configurations don't set HTTP_AUTHORIZATION for CGI scripts.
+ # If we're under mod_perl, there is a way around it...
+ eval {
+ local $SIG{__DIE__};
+ my $auth = Apache2::RequestUtil->request()->headers_in()->{Authorization};
+ $ENV{HTTP_AUTHORIZATION} = $auth if $auth;
+ } if (IS_MODPERL2() && !$ENV{HTTP_AUTHORIZATION});
+
# If we got a Authorization header, the client is back at it after being
# prompted for a password so we insert the header as is in the request.
- if($ENV{HTTP_AUTHORIZATION}){
- $req->headers->header(Authorization => $ENV{HTTP_AUTHORIZATION});
- }
+ $req->headers->header(Authorization => $ENV{HTTP_AUTHORIZATION})
+ if $ENV{HTTP_AUTHORIZATION};
my $res = $ua->request($req);
Received on Monday, 21 September 2009 19:12:20 UTC