]> git.saurik.com Git - apt.git/commitdiff
Location header in redirects should be absolute URI, but some
authorDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 28 Apr 2011 23:20:44 +0000 (01:20 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 28 Apr 2011 23:20:44 +0000 (01:20 +0200)
servers just send an absolute path so still deal with it properly

debian/changelog
methods/http.cc

index 143661b87061a8b20f8bd45bd6f88a3d7454f57e..fd10e0fcf00456cf15b2a90ad08c66929643d3c2 100644 (file)
@@ -48,8 +48,10 @@ apt (0.8.14.2) UNRELEASED; urgency=low
   * methods/http.cc:
     - add config option to ignore a closed stdin to be able to easily
       use the method as a simple standalone downloader
+    - Location header in redirects should be absolute URI, but some
+      servers just send an absolute path so still deal with it properly
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 27 Apr 2011 10:30:47 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 27 Apr 2011 17:37:58 +0200
 
 apt (0.8.14.1) unstable; urgency=low
 
index 26abc14d97b8c4340ebe3214525334c88ec22728..d3e00553cdedf997bf704c9f82081780e1841566 100644 (file)
@@ -948,7 +948,23 @@ HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
            && Srv->Result != 304    // Not Modified
            && Srv->Result != 306))  // (Not part of HTTP/1.1, reserved)
    {
-      if (!Srv->Location.empty())
+      if (Srv->Location.empty() == true);
+      else if (Srv->Location[0] == '/' && Queue->Uri.empty() == false)
+      {
+        URI Uri = Queue->Uri;
+        if (Uri.Host.empty() == false)
+        {
+           if (Uri.Port != 0)
+              strprintf(NextURI, "http://%s:%u", Uri.Host.c_str(), Uri.Port);
+           else
+              NextURI = "http://" + Uri.Host;
+        }
+        else
+           NextURI.clear();
+        NextURI.append(Srv->Location);
+        return TRY_AGAIN_OR_REDIRECT;
+      }
+      else
       {
          NextURI = Srv->Location;
          return TRY_AGAIN_OR_REDIRECT;