You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/02/08 16:51:32 UTC
[05/20] mesos git commit: Update Mesos for HTTP query string
encode/decode.
Update Mesos for HTTP query string encode/decode.
Review: https://reviews.apache.org/r/30442
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e93672be
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e93672be
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e93672be
Branch: refs/heads/master
Commit: e93672bef01f124f60fbce4699efb6c2112703b0
Parents: 93bed98
Author: Cody Maloney <co...@mesosphere.io>
Authored: Fri Jan 30 18:02:23 2015 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sat Feb 7 14:42:45 2015 -0800
----------------------------------------------------------------------
src/master/http.cpp | 20 ++++++++++++++++----
src/tests/repair_tests.cpp | 4 +++-
2 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e93672be/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 138624d..6d7b9f6 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -278,8 +278,14 @@ Future<Response> Master::Http::observe(const Request& request)
{
LOG(INFO) << "HTTP request for '" << request.path << "'";
- hashmap<string, string> values =
- process::http::query::parse(request.body);
+ Try<hashmap<string, string>> decode =
+ process::http::query::decode(request.body);
+
+ if (decode.isError()) {
+ return BadRequest("Unable to decode query string: " + decode.error());
+ }
+
+ hashmap<string, string> values = decode.get();
// Build up a JSON object of the values we recieved and send them back
// down the wire as JSON for validation / confirmation.
@@ -655,8 +661,14 @@ Future<Response> Master::Http::shutdown(const Request& request)
// Parse the query string in the request body (since this is a POST)
// in order to determine the framework ID to shutdown.
- hashmap<string, string> values =
- process::http::query::parse(request.body);
+ Try<hashmap<string, string>> decode =
+ process::http::query::decode(request.body);
+
+ if (decode.isError()) {
+ return BadRequest("Unable to decode query string: " + decode.error());
+ }
+
+ hashmap<string, string> values = decode.get();
if (values.get("frameworkId").isNone()) {
return BadRequest("Missing 'frameworkId' query parameter");
http://git-wip-us.apache.org/repos/asf/mesos/blob/e93672be/src/tests/repair_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/repair_tests.cpp b/src/tests/repair_tests.cpp
index 734d3b7..1aad5c1 100644
--- a/src/tests/repair_tests.cpp
+++ b/src/tests/repair_tests.cpp
@@ -114,7 +114,9 @@ TEST_F(HealthTest, ObserveEndpoint)
"observe",
None(),
"monitor=foo%");
- VALIDATE_BAD_RESPONSE(response, "Malformed % escape in 'foo%': '%'");
+ VALIDATE_BAD_RESPONSE(
+ response,
+ "Unable to decode query string: Malformed % escape in 'foo%': '%'");
// Empty value causes error.
response = process::http::post(