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 01:04:58 UTC

[1/2] mesos git commit: Changed the http::Headers to be a derived class from Hashmap.

Repository: mesos
Updated Branches:
  refs/heads/master 1cebd79ea -> 3424a3d1e


Changed the http::Headers to be a derived class from Hashmap.

The http::Headers should simply derive from the Hashmap class so that
all other projects (e.g., an isolator module using libprocess) will
not be broken by the recent http::Headers change (it was changed from
a hashmap to a class recently in https://reviews.apache.org/r/56116/).

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


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

Branch: refs/heads/master
Commit: d099f8d65d6626f720f743d4ea8cc049b000fe63
Parents: 1cebd79
Author: Gilbert Song <so...@gmail.com>
Authored: Thu Feb 23 16:18:36 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Feb 23 16:51:43 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/http.hpp | 64 ++++++++++------------
 3rdparty/libprocess/src/http.cpp             | 65 -----------------------
 3rdparty/libprocess/src/tests/http_tests.cpp | 18 +++----
 3 files changed, 36 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d099f8d6/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index 3a40696..52828ee 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -451,20 +451,38 @@ private:
 } // namespace header {
 
 
-class Headers
+class Headers : public hashmap<
+    std::string,
+    std::string,
+    CaseInsensitiveHash,
+    CaseInsensitiveEqual>
 {
 public:
-  typedef hashmap<
-      std::string,
-      std::string,
-      CaseInsensitiveHash,
-      CaseInsensitiveEqual> Type;
-
   Headers() {}
-  Headers(const Type& _headers) : headers(_headers) {}
+
+  Headers(const std::map<std::string, std::string>& map)
+    : hashmap<
+          std::string,
+          std::string,
+          CaseInsensitiveHash,
+          CaseInsensitiveEqual>(map) {}
+
+  Headers(std::map<std::string, std::string>&& map)
+    : hashmap<
+          std::string,
+          std::string,
+          CaseInsensitiveHash,
+          CaseInsensitiveEqual>(map) {}
+
+  Headers(std::initializer_list<std::pair<std::string, std::string>> list)
+     : hashmap<
+          std::string,
+          std::string,
+          CaseInsensitiveHash,
+          CaseInsensitiveEqual>(list) {}
 
   template <typename T>
-  Result<T> get() const
+  Result<T> header() const
   {
     Option<std::string> value = get(T::NAME);
     if (value.isNone()) {
@@ -476,34 +494,6 @@ public:
     }
     return header.get();
   }
-
-  Headers& operator=(const Type& _headers);
-
-  std::string& operator[](const std::string& key);
-
-  void put(const std::string& key, const std::string& value);
-
-  Option<std::string> get(const std::string& key) const;
-
-  std::string& at(const std::string& key);
-
-  const std::string& at(const std::string& key) const;
-
-  bool contains(const std::string& key) const;
-
-  size_t size() const;
-
-  bool empty() const;
-
-  void clear();
-
-  typename Type::iterator begin() { return headers.begin(); }
-  typename Type::iterator end() { return headers.end(); }
-  typename Type::const_iterator begin() const { return headers.cbegin(); }
-  typename Type::const_iterator end() const { return headers.cend(); }
-
-private:
-  Type headers;
 };
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/d099f8d6/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 0e37936..e17ad22 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -649,71 +649,6 @@ hashmap<string, string> WWWAuthenticate::authParam()
 } // namespace header {
 
 
-Headers& Headers::operator=(const Headers::Type& _headers)
-{
-  headers = _headers;
-  return *this;
-}
-
-
-string& Headers::operator[](const string& key)
-{
-  return headers[key];
-}
-
-
-void Headers::put(const string& key, const string& value)
-{
-  headers.put(key, value);
-}
-
-
-Option<string> Headers::get(const string& key) const
-{
-  if (headers.contains(key)) {
-    return headers.at(key);
-  }
-
-  return None();
-}
-
-
-string& Headers::at(const string& key)
-{
-  return headers.at(key);
-}
-
-
-const string& Headers::at(const string& key) const
-{
-  return headers.at(key);
-}
-
-
-bool Headers::contains(const string& key) const
-{
-  return headers.contains(key);
-}
-
-
-size_t Headers::size() const
-{
-  return headers.size();
-}
-
-
-bool Headers::empty() const
-{
-  return headers.empty();
-}
-
-
-void Headers::clear()
-{
-  headers.clear();
-}
-
-
 OK::OK(const JSON::Value& value, const Option<string>& jsonp)
   : Response(Status::OK)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d099f8d6/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 fb4da9a..71e8ad6 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.get<http::header::WWWAuthenticate>();
+    headers.header<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.get<http::header::WWWAuthenticate>();
+  header = headers.header<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.get<http::header::WWWAuthenticate>();
+  header = headers.header<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.get<http::header::WWWAuthenticate>();
+  header = headers.header<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = " ";
-  header = headers.get<http::header::WWWAuthenticate>();
+  header = headers.header<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = "Digest";
-  header = headers.get<http::header::WWWAuthenticate>();
+  header = headers.header<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = "Digest =";
-  header = headers.get<http::header::WWWAuthenticate>();
+  header = headers.header<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = "Digest ,,";
-  header = headers.get<http::header::WWWAuthenticate>();
+  header = headers.header<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 
   headers["Www-Authenticate"] = "Digest uri=\"/dir/index.html\",qop=auth";
-  header = headers.get<http::header::WWWAuthenticate>();
+  header = headers.header<http::header::WWWAuthenticate>();
 
   EXPECT_ERROR(header);
 }


[2/2] mesos git commit: Renamed http::Headers get() to header() due to the libprocess change.

Posted by ji...@apache.org.
Renamed http::Headers get() to header() due to the libprocess change.

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


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

Branch: refs/heads/master
Commit: 3424a3d1e98291e5c241961a1824f0eaabf8e103
Parents: d099f8d
Author: Gilbert Song <so...@gmail.com>
Authored: Thu Feb 23 16:37:01 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Feb 23 16:51:48 2017 -0800

----------------------------------------------------------------------
 src/uri/fetchers/docker.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3424a3d1/src/uri/fetchers/docker.cpp
----------------------------------------------------------------------
diff --git a/src/uri/fetchers/docker.cpp b/src/uri/fetchers/docker.cpp
index 68f380d..b61a71a 100644
--- a/src/uri/fetchers/docker.cpp
+++ b/src/uri/fetchers/docker.cpp
@@ -643,7 +643,7 @@ Future<http::Headers> DockerFetcherPluginProcess::getAuthHeader(
     const http::Response& response)
 {
   Result<http::header::WWWAuthenticate> header =
-    response.headers.get<http::header::WWWAuthenticate>();
+    response.headers.header<http::header::WWWAuthenticate>();
 
   if (header.isError()) {
     return Failure(