You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/02/24 02:15:28 UTC

[2/2] mesos git commit: Renamed 'Headers' class templete method to 'get()'.

Renamed 'Headers' class templete method to 'get()'.

This patch changed the 'Headers' class templete method from 'header()'
to 'get()' since 'get' is more accurate for grabbing a header object
while it can be defined as different type (e.g., WWWAuthenticate).

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


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

Branch: refs/heads/1.2.x
Commit: 2949ca0abb8fb6bd97d67a35b2a22377198f8a21
Parents: de995a3
Author: Gilbert Song <so...@gmail.com>
Authored: Thu Feb 23 18:03:04 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Feb 23 18:15:24 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/http.hpp | 11 ++++++++++-
 3rdparty/libprocess/src/tests/http_tests.cpp | 18 +++++++++---------
 2 files changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2949ca0a/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index 52828ee..eb2c87d 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -482,7 +482,7 @@ public:
           CaseInsensitiveEqual>(list) {}
 
   template <typename T>
-  Result<T> header() const
+  Result<T> get() const
   {
     Option<std::string> value = get(T::NAME);
     if (value.isNone()) {
@@ -494,6 +494,15 @@ public:
     }
     return header.get();
   }
+
+  Option<std::string> get(const std::string& key) const
+  {
+    return hashmap<
+        std::string,
+        std::string,
+        CaseInsensitiveHash,
+        CaseInsensitiveEqual>::get(key);
+  }
 };
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/2949ca0a/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index 71e8ad6..fb4da9a 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -1527,7 +1527,7 @@ TEST_P(HTTPTest, WWWAuthenticateHeader)
   headers["Www-Authenticate"] = "Basic realm=\"basic-realm\"";
 
   Result<http::header::WWWAuthenticate> header =
-    headers.header<http::header::WWWAuthenticate>();
+    headers.get<http::header::WWWAuthenticate>();
 
   ASSERT_SOME(header);
 
@@ -1536,7 +1536,7 @@ TEST_P(HTTPTest, WWWAuthenticateHeader)
   EXPECT_EQ("basic-realm", header->authParam()["realm"]);
 
   headers.clear();
-  header = headers.header<http::header::WWWAuthenticate>();
+  header = headers.get<http::header::WWWAuthenticate>();
 
   EXPECT_NONE(header);
 
@@ -1545,7 +1545,7 @@ TEST_P(HTTPTest, WWWAuthenticateHeader)
     "service=\"registry.docker.io\","
     "scope=\"repository:gilbertsong/inky:pull\"";
 
-  header = headers.header<http::header::WWWAuthenticate>();
+  header = headers.get<http::header::WWWAuthenticate>();
 
   ASSERT_SOME(header);
 
@@ -1556,32 +1556,32 @@ TEST_P(HTTPTest, WWWAuthenticateHeader)
   EXPECT_EQ("repository:gilbertsong/inky:pull", header->authParam()["scope"]);
 
   headers["Www-Authenticate"] = "";
-  header = headers.header<http::header::WWWAuthenticate>();
+  header = headers.get<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = " ";
-  header = headers.header<http::header::WWWAuthenticate>();
+  header = headers.get<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = "Digest";
-  header = headers.header<http::header::WWWAuthenticate>();
+  header = headers.get<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = "Digest =";
-  header = headers.header<http::header::WWWAuthenticate>();
+  header = headers.get<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = "Digest ,,";
-  header = headers.header<http::header::WWWAuthenticate>();
+  header = headers.get<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = "Digest uri=\"/dir/index.html\",qop=auth";
-  header = headers.header<http::header::WWWAuthenticate>();
+  header = headers.get<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 }