Francois Gouget : testbot/web: Document and slightly optimize PageBase::Redirect().
Alexandre Julliard
julliard at winehq.org
Thu Sep 26 12:53:44 CDT 2019
Module: tools
Branch: master
Commit: 900e6913a2c2eefac07a0947fcc254aa62974410
URL: https://source.winehq.org/git/tools.git/?a=commit;h=900e6913a2c2eefac07a0947fcc254aa62974410
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Thu Sep 26 13:35:22 2019 +0200
testbot/web: Document and slightly optimize PageBase::Redirect().
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
testbot/lib/WineTestBot/CGI/PageBase.pm | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/testbot/lib/WineTestBot/CGI/PageBase.pm b/testbot/lib/WineTestBot/CGI/PageBase.pm
index c1a8c8c..e3d2e04 100644
--- a/testbot/lib/WineTestBot/CGI/PageBase.pm
+++ b/testbot/lib/WineTestBot/CGI/PageBase.pm
@@ -395,18 +395,18 @@ sub Redirect($$$)
$self->SetCookies();
if (substr($Location, 0, 4) ne "http")
{
- my $Protocol = "http";
- if (SecureConnection())
- {
- $Protocol .= "s";
- }
+ # Use the same protocol as for the current page. To force switching to
+ # https the caller should use MakeSecureURL().
+ my $Protocol = SecureConnection() ? "https://" : "http://";
if (substr($Location, 0, 1) ne "/")
{
+ # Despite its name, Request->uri only contains the path portion of the
+ # URI, excluding the protocol, hostname and parameters!
my $URI = $self->{Request}->uri;
- $URI =~ s=^(.*)/[^/]*$=$1/=;
- $Location = $URI . $Location;
+ $URI =~ s=^(.*)/[^/]*$=$1/$Location=;
+ $Location = $URI;
}
- $Location = $Protocol . "://" . $ENV{"HTTP_HOST"} . $Location;
+ $Location = $Protocol . $ENV{"HTTP_HOST"} . $Location;
}
$self->{Request}->headers_out->set("Location", $Location);
$self->{Request}->status(Apache2::Const::REDIRECT);
More information about the wine-cvs
mailing list