Encapsulate logic for determining if an SSL request has been made.

Refactor core modules to use that.
This commit is contained in:
Colin Kuskie 2009-08-19 18:25:00 +00:00
parent 39127b7ec0
commit 1c9908f490
5 changed files with 23 additions and 17 deletions

View file

@ -43,7 +43,7 @@ These methods are available from this package:
=head2 callerIsSearchSite ( )
returns true if the remote address matches a site which is a known indexer or spider.
Returns true if the remote address matches a site which is a known indexer or spider.
=cut
@ -65,7 +65,8 @@ sub callerIsSearchSite {
=head2 clientIsSpider ( )
returns true is the client/agent is a spider/indexer or some other non-human interface
Returns true is the client/agent is a spider/indexer or some other non-human interface, determined
by checking the user agent against a list of known spiders.
=cut
@ -166,7 +167,7 @@ sub new {
=head2 requestNotViewed ( )
returns true is the client/agent is a spider/indexer or some other non-human interface
Returns true is the client/agent is a spider/indexer or some other non-human interface
=cut
@ -181,6 +182,19 @@ sub requestNotViewed {
}
#-------------------------------------------------------------------
=head2 sslRequest ( )
Returns true if a https request was made.
=cut
sub sslRequest {
my $self = shift;
return ($self->get('HTTPS') eq 'on' || $self->get('SSLPROXY') ? 1 : 0);
}
1;

View file

@ -148,11 +148,7 @@ sub extras {
my $cdnCfg = $self->session->config->get('cdn');
if ( $cdnCfg and $cdnCfg->{'enabled'} and $cdnCfg->{'extrasCdn'} ) {
unless ( $path and grep $path =~ m/$_/, @{ $cdnCfg->{'extrasExclude'} } ) {
if ($cdnCfg->{'extrasSsl'}
and ( $self->session->env->get('HTTPS') eq 'on'
or $self->session->env->get('SSLPROXY') )
)
{
if ($cdnCfg->{'extrasSsl'} && $self->session->env->sslRequest) {
$url = $cdnCfg->{'extrasSsl'};
}
else {
@ -291,7 +287,7 @@ sub forceSecureConnection {
my $url = shift;
my ($conf, $env, $http) = $self->session->quick(qw(config env http));
if ($conf->get("sslEnabled") && $env->get("HTTPS") ne "on" && !$env->get("SSLPROXY")){
if ($conf->get("sslEnabled") && !$env->sslRequest){
$url = $self->session->url->page if(! $url);
$url = $env->get('QUERY_STRING') if(! $url);
@ -354,7 +350,7 @@ sub getSiteURL {
$site = $sitenames->[0];
}
my $proto = "http://";
if ($self->session->env->get("HTTPS") eq "on") {
if ($self->session->env->sslRequest) {
$proto = "https://";
}
my $port = "";