Skip to content

Commit

Permalink
Add FullUrlIgnorePort directive
Browse files Browse the repository at this point in the history
This allows FullUrl to work with nonstandard ports, other than default
http port 80.
  • Loading branch information
jonjensen committed Dec 3, 2009
1 parent 1c761a2 commit dc2c39d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/Vend/Config.pm
Expand Up @@ -467,6 +467,7 @@ sub global_directives {
['GlobalSub', 'subroutine', ''],
['Database', 'database', ''],
['FullUrl', 'yesno', 'No'],
['FullUrlIgnorePort', 'yesno', 'No'],
['Locale', 'locale', ''],
['HitCount', 'yesno', 'No'],
['IpHead', 'yesno', 'No'],
Expand Down
26 changes: 14 additions & 12 deletions lib/Vend/Dispatch.pm
Expand Up @@ -920,19 +920,21 @@ sub adjust_cgi {

$CGI::host = $host || $CGI::ip;

$CGI::user = $CGI::remote_user if $CGI::remote_user;
undef $CGI::authorization if $CGI::remote_user;
$CGI::user = $CGI::remote_user, undef $CGI::authorization
if $CGI::remote_user;

unless ($Global::FullUrl) {
$CGI::script_name = $CGI::script_path;
}
else {
if($CGI::server_port eq '80') { $CGI::server_port = ''; }
else { $CGI::server_port = ":$CGI::server_port"; }
$CGI::script_name = $CGI::server_name .
$CGI::server_port .
$CGI::script_path;
}
if ($Global::FullUrl) {
if ($Global::FullUrlIgnorePort or $CGI::server_port eq '80') {
$CGI::server_port = '';
}
else {
$CGI::server_port = ":$CGI::server_port";
}
$CGI::script_name = $CGI::server_name . $CGI::server_port . $CGI::script_path;
}
else {
$CGI::script_name = $CGI::script_path;
}
}

use vars qw/@NoHistory/;
Expand Down
4 changes: 3 additions & 1 deletion lib/Vend/Server.pm
Expand Up @@ -181,8 +181,10 @@ sub map_misc_cgi {
$CGI::host = $CGI::remote_host || $CGI::remote_addr;
$CGI::user = $CGI::remote_user;

my $server_host_without_port = $CGI::server_host;
$server_host_without_port =~ s/:.*// if $Global::FullUrlIgnorePort;
$CGI::script_path = $CGI::script_name;
$CGI::script_name = $CGI::server_host . $CGI::script_path
$CGI::script_name = $server_host_without_port . $CGI::script_path
if $Global::FullUrl;
}

Expand Down

0 comments on commit dc2c39d

Please sign in to comment.