Repository: mesos
Updated Branches:
  refs/heads/master 92b360532 -> 5ce7b0586


Fixed fetcher failing for FTP URIs.

The response code for successful FTP file transfers is 226, while it is 200 for 
HTTP. The fetcher has been changed to check for a response code of 226 for FTP 
URIs.

Fixes MESOS-3060.

Review: https://reviews.apache.org/r/36547


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5ce7b058
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5ce7b058
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5ce7b058

Branch: refs/heads/master
Commit: 5ce7b05864b291bb80be8763cfa057bc30941cb0
Parents: 92b3605
Author: Jan Schlicht <[email protected]>
Authored: Fri Jul 17 11:22:26 2015 +0200
Committer: Bernd Mathiske <[email protected]>
Committed: Fri Jul 17 11:22:26 2015 +0200

----------------------------------------------------------------------
 src/launcher/fetcher.cpp | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5ce7b058/src/launcher/fetcher.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/fetcher.cpp b/src/launcher/fetcher.cpp
index 8aee490..5d3fe9e 100644
--- a/src/launcher/fetcher.cpp
+++ b/src/launcher/fetcher.cpp
@@ -117,15 +117,33 @@ static Try<string> downloadWithNet(
     const string& sourceUri,
     const string& destinationPath)
 {
-  LOG(INFO) <<  "Downloading resource from '" << sourceUri
+  // The net::download function only supports these protocols.
+  CHECK(strings::startsWith(sourceUri, "http://";)  ||
+        strings::startsWith(sourceUri, "https://";) ||
+        strings::startsWith(sourceUri, "ftp://";)   ||
+        strings::startsWith(sourceUri, "ftps://"));
+
+  LOG(INFO) << "Downloading resource from '" << sourceUri
             << "' to '" << destinationPath << "'";
 
   Try<int> code = net::download(sourceUri, destinationPath);
   if (code.isError()) {
     return Error("Error downloading resource: " + code.error());
-  } else if (code.get() != 200) {
-    return Error("Error downloading resource, received HTTP/FTP return code " +
-                 stringify(code.get()));
+  } else {
+    // The status code for successful HTTP requests is 200, the status code
+    // for successful FTP file transfers is 226.
+    if (strings::startsWith(sourceUri, "ftp://";) ||
+        strings::startsWith(sourceUri, "ftps://")) {
+      if (code.get() != 226) {
+        return Error("Error downloading resource, received FTP return code " +
+                     stringify(code.get()));
+      }
+    } else {
+      if (code.get() != 200) {
+        return Error("Error downloading resource, received HTTP return code " +
+                     stringify(code.get()));
+      }
+    }
   }
 
   return destinationPath;

Reply via email to