You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2018/10/08 14:42:11 UTC

[mesos] branch master updated (aa98a49 -> 17c1d7d)

This is an automated email from the ASF dual-hosted git repository.

alexr pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from aa98a49  Moved `get_agent_address` from `util.py` to `mesos.py` in new CLI.
     new 4bf72d9  Used delegating constructors in `Response` types.
     new 17c1d7d  Fused constructors of `MethodNotAllowed` into one.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 3rdparty/libprocess/include/process/http.hpp | 50 +++++++++++-----------------
 1 file changed, 20 insertions(+), 30 deletions(-)


[mesos] 02/02: Fused constructors of `MethodNotAllowed` into one.

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alexr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 17c1d7d41a5489cc865f787deeeb2b91865b8fe1
Author: Alexander Rukletsov <al...@apache.org>
AuthorDate: Sun Oct 7 16:31:56 2018 +0200

    Fused constructors of `MethodNotAllowed` into one.
    
    There is no good reason to provide two c-tors for `MethodNotAllowed`,
    with one taking `requestMethod` and one not. Instead, an `Option<>`
    can be used. This also removes the need for copy-paste in the c-tor
    body.
    
    Review: https://reviews.apache.org/r/68945
---
 3rdparty/libprocess/include/process/http.hpp | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index 00dc2fd..bbcd0ba 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -753,16 +753,9 @@ struct MethodNotAllowed : Response
   // According to RFC 2616, "An Allow header field MUST be present in a
   // 405 (Method Not Allowed) response".
 
-  explicit MethodNotAllowed(
-      const std::initializer_list<std::string>& allowedMethods)
-    : Response("405 Method Not Allowed.", Status::METHOD_NOT_ALLOWED)
-  {
-    headers["Allow"] = strings::join(", ", allowedMethods);
-  }
-
   MethodNotAllowed(
       const std::initializer_list<std::string>& allowedMethods,
-      const std::string& requestMethod)
+      const Option<std::string>& requestMethod = None())
     : Response(
         constructBody(allowedMethods, requestMethod),
         Status::METHOD_NOT_ALLOWED)
@@ -773,11 +766,15 @@ struct MethodNotAllowed : Response
 private:
   static std::string constructBody(
       const std::initializer_list<std::string>& allowedMethods,
-      const std::string& requestMethod)
+      const Option<std::string>& requestMethod)
   {
-    return "405 Method Not Allowed. Expecting one of { '" +
-         strings::join("', '", allowedMethods) + "' }, but received '" +
-         requestMethod + "'.";
+    return
+        "405 Method Not Allowed. Expecting one of { '" +
+        strings::join("', '", allowedMethods) + "' }" +
+        (requestMethod.isSome()
+           ? ", but received '" + requestMethod.get() + "'"
+           : "") +
+        ".";
   }
 };
 


[mesos] 01/02: Used delegating constructors in `Response` types.

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alexr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 4bf72d9851e924589ae769c9706eae0e82f2a254
Author: Alexander Rukletsov <al...@apache.org>
AuthorDate: Sun Oct 7 15:55:13 2018 +0200

    Used delegating constructors in `Response` types.
    
    For clarity and brevity, use delegating constructors (available
    since C++11) in descendants of the `Response` class.
    
    Review: https://reviews.apache.org/r/68944
---
 3rdparty/libprocess/include/process/http.hpp | 29 +++++++++++-----------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index cef511a..00dc2fd 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -702,7 +702,7 @@ struct TemporaryRedirect : Response
 struct BadRequest : Response
 {
   BadRequest()
-    : Response("400 Bad Request.", Status::BAD_REQUEST) {}
+    : BadRequest("400 Bad Request.") {}
 
   explicit BadRequest(const std::string& body)
     : Response(body, Status::BAD_REQUEST) {}
@@ -712,14 +712,7 @@ struct BadRequest : Response
 struct Unauthorized : Response
 {
   explicit Unauthorized(const std::vector<std::string>& challenges)
-    : Response("401 Unauthorized.", Status::UNAUTHORIZED)
-  {
-    // TODO(arojas): Many HTTP client implementations do not support
-    // multiple challenges within a single 'WWW-Authenticate' header.
-    // Once MESOS-3306 is fixed, we can use multiple entries for the
-    // same header.
-    headers["WWW-Authenticate"] = strings::join(", ", challenges);
-  }
+    : Unauthorized(challenges, "401 Unauthorized.") {}
 
   Unauthorized(
       const std::vector<std::string>& challenges,
@@ -738,7 +731,7 @@ struct Unauthorized : Response
 struct Forbidden : Response
 {
   Forbidden()
-    : Response("403 Forbidden.", Status::FORBIDDEN) {}
+    : Forbidden("403 Forbidden.") {}
 
   explicit Forbidden(const std::string& body)
     : Response(body, Status::FORBIDDEN) {}
@@ -748,7 +741,7 @@ struct Forbidden : Response
 struct NotFound : Response
 {
   NotFound()
-    : Response("404 Not Found.", Status::NOT_FOUND) {}
+    : NotFound("404 Not Found.") {}
 
   explicit NotFound(const std::string& body)
     : Response(body, Status::NOT_FOUND) {}
@@ -792,7 +785,7 @@ private:
 struct NotAcceptable : Response
 {
   NotAcceptable()
-    : Response("406 Not Acceptable.", Status::NOT_ACCEPTABLE) {}
+    : NotAcceptable("406 Not Acceptable.") {}
 
   explicit NotAcceptable(const std::string& body)
     : Response(body, Status::NOT_ACCEPTABLE) {}
@@ -802,7 +795,7 @@ struct NotAcceptable : Response
 struct Conflict : Response
 {
   Conflict()
-    : Response("409 Conflict.", Status::CONFLICT) {}
+    : Conflict("409 Conflict.") {}
 
   explicit Conflict(const std::string& body)
     : Response(body, Status::CONFLICT) {}
@@ -812,7 +805,7 @@ struct Conflict : Response
 struct PreconditionFailed : Response
 {
   PreconditionFailed()
-    : Response("412 Precondition Failed.", Status::PRECONDITION_FAILED) {}
+    : PreconditionFailed("412 Precondition Failed.") {}
 
   explicit PreconditionFailed(const std::string& body)
     : Response(body, Status::PRECONDITION_FAILED) {}
@@ -822,7 +815,7 @@ struct PreconditionFailed : Response
 struct UnsupportedMediaType : Response
 {
   UnsupportedMediaType()
-    : Response("415 Unsupported Media Type.", Status::UNSUPPORTED_MEDIA_TYPE) {}
+    : UnsupportedMediaType("415 Unsupported Media Type.") {}
 
   explicit UnsupportedMediaType(const std::string& body)
     : Response(body, Status::UNSUPPORTED_MEDIA_TYPE) {}
@@ -832,7 +825,7 @@ struct UnsupportedMediaType : Response
 struct InternalServerError : Response
 {
   InternalServerError()
-    : Response("500 Internal Server Error.", Status::INTERNAL_SERVER_ERROR) {}
+    : InternalServerError("500 Internal Server Error.") {}
 
   explicit InternalServerError(const std::string& body)
     : Response(body, Status::INTERNAL_SERVER_ERROR) {}
@@ -842,7 +835,7 @@ struct InternalServerError : Response
 struct NotImplemented : Response
 {
   NotImplemented()
-    : Response("501 Not Implemented.", Status::NOT_IMPLEMENTED) {}
+    : NotImplemented("501 Not Implemented.") {}
 
   explicit NotImplemented(const std::string& body)
     : Response(body, Status::NOT_IMPLEMENTED) {}
@@ -852,7 +845,7 @@ struct NotImplemented : Response
 struct ServiceUnavailable : Response
 {
   ServiceUnavailable()
-    : Response("503 Service Unavailable.", Status::SERVICE_UNAVAILABLE) {}
+    : ServiceUnavailable("503 Service Unavailable.") {}
 
   explicit ServiceUnavailable(const std::string& body)
     : Response(body, Status::SERVICE_UNAVAILABLE) {}