You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2016/11/22 03:27:33 UTC
[13/13] mesos git commit: Removed `convert()` continuations in favor
of using `readAll()`.
Removed `convert()` continuations in favor of using `readAll()`.
Review: https://reviews.apache.org/r/53488/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d06d7456
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d06d7456
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d06d7456
Branch: refs/heads/master
Commit: d06d74562740767f0750e10907a327c5b45fef4c
Parents: d30039d
Author: Anand Mazumdar <an...@apache.org>
Authored: Mon Nov 21 18:08:12 2016 -0800
Committer: Anand Mazumdar <an...@apache.org>
Committed: Mon Nov 21 19:27:08 2016 -0800
----------------------------------------------------------------------
3rdparty/libprocess/src/http.cpp | 49 ++++++-----------------------------
1 file changed, 8 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d06d7456/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index ca7c948..0c2dfd3 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -937,56 +937,23 @@ string encode(const Request& request)
}
-// Forward declarations.
-Future<string> _convert(
- Pipe::Reader reader,
- const std::shared_ptr<string>& buffer,
- const string& read);
-Response __convert(
- const Response& pipeResponse,
- const string& body);
-
-
// Returns a 'BODY' response once the body of the provided
// 'PIPE' response can be read completely.
Future<Response> convert(const Response& pipeResponse)
{
- std::shared_ptr<string> buffer(new string());
-
CHECK_EQ(Response::PIPE, pipeResponse.type);
CHECK_SOME(pipeResponse.reader);
Pipe::Reader reader = pipeResponse.reader.get();
- return reader.read()
- .then(lambda::bind(&_convert, reader, buffer, lambda::_1))
- .then(lambda::bind(&__convert, pipeResponse, lambda::_1));
-}
-
-
-Future<string> _convert(
- Pipe::Reader reader,
- const std::shared_ptr<string>& buffer,
- const string& read)
-{
- if (read.empty()) { // EOF.
- return *buffer;
- }
-
- buffer->append(read);
-
- return reader.read()
- .then(lambda::bind(&_convert, reader, buffer, lambda::_1));
-}
-
-
-Response __convert(const Response& pipeResponse, const string& body)
-{
- Response bodyResponse = pipeResponse;
- bodyResponse.type = Response::BODY;
- bodyResponse.body = body;
- bodyResponse.reader = None(); // Remove the reader.
- return bodyResponse;
+ return reader.readAll()
+ .then([pipeResponse](const string& body) {
+ Response bodyResponse = pipeResponse;
+ bodyResponse.type = Response::BODY;
+ bodyResponse.body = body;
+ bodyResponse.reader = None(); // Remove the reader.
+ return bodyResponse;
+ });
}