diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 69e646ba2..9b6e9ee49 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -310,7 +310,7 @@ sub checkView { my $self = shift; return $self->session->privilege->noAccess() unless $self->canView; my ($conf, $env, $var, $http) = $self->session->quick(qw(config env var http)); - if ($conf->get("sslEnabled") && $self->get("encryptPage") && $env->get("HTTPS") ne "on" && !$env->get("SSLPROXY")) { + if ($conf->get("sslEnabled") && $self->get("encryptPage") && ! $env->sslRequest) { # getUrl already changes url to https if 'encryptPage' $http->setRedirect($self->getUrl); $http->sendHeader; diff --git a/lib/WebGUI/Form/Captcha.pm b/lib/WebGUI/Form/Captcha.pm index ebfc4a855..deb9832df 100644 --- a/lib/WebGUI/Form/Captcha.pm +++ b/lib/WebGUI/Form/Captcha.pm @@ -161,7 +161,7 @@ sub toHtml { my $env = $self->session->env; my $pubKey = $self->session->setting->get('recaptchaPublicKey'); my $server = "http://api.recaptcha.net"; - if ($env->get("HTTPS") eq "on" || $env->get("SSLPROXY")) { + if ($env->sslRequest) { $server = "http://api-secure.recaptcha.net"; } return diff --git a/lib/WebGUI/Session/Env.pm b/lib/WebGUI/Session/Env.pm index 727164599..a147e51f7 100644 --- a/lib/WebGUI/Session/Env.pm +++ b/lib/WebGUI/Session/Env.pm @@ -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; diff --git a/lib/WebGUI/Session/Url.pm b/lib/WebGUI/Session/Url.pm index 03cc7e3ad..fe6a2daf1 100644 --- a/lib/WebGUI/Session/Url.pm +++ b/lib/WebGUI/Session/Url.pm @@ -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 = ""; diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index 6bb1fc50a..c07dbd7f0 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -1273,11 +1273,7 @@ sub getUrl { and -e $self->getPath . '/.cdn' ) { my $sep = '/'; # separator, if not already present trailing - if ($cdnCfg->{'sslAlt'} - and ( $self->session->env->get('HTTPS') eq 'on' - or $self->session->env->get('SSLPROXY') ) - ) - { + if ($cdnCfg->{'sslAlt'} && $self->session->env->sslRequest) { if ( $cdnCfg->{'sslUrl'} ) { substr( $cdnCfg->{'sslUrl'}, -1 ) eq '/' and $sep = ''; $url = $cdnCfg->{'sslUrl'} . $sep . $self->getDirectoryId;