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 2016/05/10 17:03:09 UTC
[2/2] mesos git commit: Constructed the error string in
MethodNotAllowed.
Constructed the error string in MethodNotAllowed.
This avoids code duplication and differences in wording when
`MethodNotAllowed` response is returned.
Review: https://reviews.apache.org/r/46504/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2e7de663
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2e7de663
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2e7de663
Branch: refs/heads/master
Commit: 2e7de663fccf20f17712f5e07d204eb44db187c6
Parents: 9aacd20
Author: Jacob Janco <jj...@gmail.com>
Authored: Tue May 10 18:05:44 2016 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Tue May 10 19:02:24 2016 +0200
----------------------------------------------------------------------
3rdparty/libprocess/include/process/http.hpp | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2e7de663/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index 8f4eabc..3b7e2c4 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -583,11 +583,22 @@ struct MethodNotAllowed : Response
MethodNotAllowed(
const std::initializer_list<std::string>& allowedMethods,
- const std::string& body)
- : Response(body, Status::METHOD_NOT_ALLOWED)
+ const std::string& requestMethod)
+ : Response(
+ constructBody(allowedMethods, requestMethod),
+ Status::METHOD_NOT_ALLOWED)
{
headers["Allow"] = strings::join(", ", allowedMethods);
}
+
+private:
+ static std::string constructBody(
+ const std::initializer_list<std::string>& allowedMethods,
+ const std::string& requestMethod)
+ {
+ return "Expecting one of { '" + strings::join("', '", allowedMethods) +
+ "' }, but received '" + requestMethod + "'";
+ }
};