Returns a 'BODY' response once the body of the provided 'PIPE' response can be read completely.
| 1106 | // Returns a 'BODY' response once the body of the provided |
| 1107 | // 'PIPE' response can be read completely. |
| 1108 | Future<Response> convert(const Response& pipeResponse) |
| 1109 | { |
| 1110 | CHECK_EQ(Response::PIPE, pipeResponse.type); |
| 1111 | CHECK_SOME(pipeResponse.reader); |
| 1112 | |
| 1113 | Pipe::Reader reader = pipeResponse.reader.get(); |
| 1114 | |
| 1115 | return reader.readAll() |
| 1116 | .then([pipeResponse](const string& body) { |
| 1117 | Response bodyResponse = pipeResponse; |
| 1118 | bodyResponse.type = Response::BODY; |
| 1119 | bodyResponse.body = body; |
| 1120 | bodyResponse.reader = None(); // Remove the reader. |
| 1121 | return bodyResponse; |
| 1122 | }); |
| 1123 | } |
| 1124 | |
| 1125 | |
| 1126 | class ConnectionProcess : public Process<ConnectionProcess> |