[PATCH] testbot/web: Document and slightly optimize PageBase::Redirect().

Francois Gouget fgouget at codeweavers.com
Thu Sep 26 06:35:22 CDT 2019


Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 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 c1a8c8cbf..e3d2e04d5 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);
-- 
2.20.1




More information about the wine-devel mailing list