Updated mesos to reflect base64::decode returning a Try.

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


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

Branch: refs/heads/master
Commit: 1e21d494b2b90aae66ee814a36c17d8bf13166ac
Parents: 57e9389
Author: Benjamin Mahler <[email protected]>
Authored: Mon Aug 17 15:10:41 2015 -0700
Committer: Benjamin Mahler <[email protected]>
Committed: Mon Aug 17 17:05:25 2015 -0700

----------------------------------------------------------------------
 src/master/http.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1e21d494/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 877c1f9..d016b3c 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -1346,10 +1346,14 @@ Result<Credential> Master::Http::authenticate(const 
Request& request) const
     return Error("Missing 'Authorization' request header");
   }
 
-  const string& decoded =
+  Try<string> decode =
     base64::decode(strings::split(authorization.get(), " ", 2)[1]);
 
-  const vector<string>& pairs = strings::split(decoded, ":", 2);
+  if (decode.isError()) {
+    return Error("Failed to decode 'Authorization' header: " + decode.error());
+  }
+
+  vector<string> pairs = strings::split(decode.get(), ":", 2);
 
   if (pairs.size() != 2) {
     return Error("Malformed 'Authorization' request header");

Reply via email to