Skip to content

Commit

Permalink
Item14380: A couple of additional tweaks:
Browse files Browse the repository at this point in the history
This version has been tested with an apache reverse proxy in front of a
plain CGI foswiki and a mod_perl foswiki. Tested with http, https, and
non-standard ports.  All seem to be working fine.

Note that FuncTests::test_getUrl fails, but it appears that the test is
broken.

Also HomePagePlugin tests fail, but it does work when used live. So
more possibly broken tests.

FuncTests has 1 unexpected results (of 58):
   * F: FuncTests::test_getUrlHost
HomePagePluginSuite has 2 unexpected results (of 6):
   * F: HomePagePluginSuite::test_login
   * F: HomePagePluginSuite::test_view
  • Loading branch information
gac410 committed Dec 1, 2017
1 parent 707f775 commit 7e556d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion core/lib/Foswiki/Engine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,12 @@ sub _getConnectionData {
$proto = $1;
$host = $2;
}
elsif ( defined $Foswiki::cfg{DefaultUrlHost} ) {
($host) = $Foswiki::cfg{DefaultUrlHost} =~ m#https?://([^:/]+)#i;
}
}

#SMELL: Give up - no obvious hostname in the request.
#SMELL: Give up - no obvious hostname in the request and no default.
unless ($host) {
$host = 'localhost';
}
Expand Down
6 changes: 3 additions & 3 deletions core/lib/Foswiki/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ sub url {
$url = $Foswiki::cfg{DefaultUrlHost};
}
else {
my $host = $this->header('Host');
my $port = $this->serverPort();
my ( $client, $protocol, $host, $port ) =
Foswiki::Engine::_getConnectionData();
$port = ( $port && $port != 80 && $port != 443 ) ? ":$port" : '';
$url =
$host
? $this->protocol . '://' . $host . $port
? $protocol . '://' . $host . $port
: $Foswiki::cfg{DefaultUrlHost};
}
return $url if $base;
Expand Down

0 comments on commit 7e556d4

Please sign in to comment.