]> git.saurik.com Git - apt.git/blobdiff - methods/server.cc
CMake: test/libapt: Use a prebuilt GTest library if available
[apt.git] / methods / server.cc
index d0b6ef3d7c5d4141f05285f9885592f67897d14e..af7276badd7a9f2ca2b7670b78ebb14b4f4f2efc 100644 (file)
@@ -208,8 +208,16 @@ bool ServerState::HeaderLine(string Line)
    if (stringcasecmp(Tag,"Connection:") == 0)
    {
       if (stringcasecmp(Val,"close") == 0)
    if (stringcasecmp(Tag,"Connection:") == 0)
    {
       if (stringcasecmp(Val,"close") == 0)
+      {
         Persistent = false;
         Persistent = false;
-      if (stringcasecmp(Val,"keep-alive") == 0)
+        Pipeline = false;
+        /* Some servers send error pages (as they are dynamically generated)
+           for simplicity via a connection close instead of e.g. chunked,
+           so assuming an always closing server only if we get a file + close */
+        if (Result >= 200 && Result < 300)
+           PipelineAllowed = false;
+      }
+      else if (stringcasecmp(Val,"keep-alive") == 0)
         Persistent = true;
       return true;
    }
         Persistent = true;
       return true;
    }
@@ -227,6 +235,15 @@ bool ServerState::HeaderLine(string Line)
       return true;
    }
 
       return true;
    }
 
+   if (stringcasecmp(Tag, "Accept-Ranges:") == 0)
+   {
+      std::string ranges = ',' + Val + ',';
+      ranges.erase(std::remove(ranges.begin(), ranges.end(), ' '), ranges.end());
+      if (ranges.find(",bytes,") == std::string::npos)
+        RangesAllowed = false;
+      return true;
+   }
+
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/
@@ -252,6 +269,7 @@ void ServerState::Reset(bool const Everything)                              /*{{{*/
    if (Everything)
    {
       Persistent = false; Pipeline = false; PipelineAllowed = true;
    if (Everything)
    {
       Persistent = false; Pipeline = false; PipelineAllowed = true;
+      RangesAllowed = true;
    }
 }
                                                                        /*}}}*/
    }
 }
                                                                        /*}}}*/