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() + "'" + : "") + + "."; } };