TODO(bmahler): Pull up a more generic helper for making it easy to send calls and get back responses. Ideally getting back the appropriate Response::X message (e.g. Response::GetAgents).
| 7650 | // to send calls and get back responses. Ideally getting back the |
| 7651 | // appropriate Response::X message (e.g. Response::GetAgents). |
| 7652 | Future<v1::master::Response> post( |
| 7653 | const process::PID<master::Master>& pid, |
| 7654 | const v1::master::Call& call) |
| 7655 | { |
| 7656 | http::Headers headers = createBasicAuthHeaders(DEFAULT_CREDENTIAL); |
| 7657 | headers["Accept"] = stringify(ContentType::PROTOBUF); |
| 7658 | |
| 7659 | return http::post( |
| 7660 | pid, |
| 7661 | "api/v1", |
| 7662 | headers, |
| 7663 | serialize(ContentType::PROTOBUF, call), |
| 7664 | stringify(ContentType::PROTOBUF)) |
| 7665 | .then([](const http::Response& response) |
| 7666 | -> Future<v1::master::Response> { |
| 7667 | if (response.status != http::OK().status) { |
| 7668 | return Failure("Unexpected response status " + response.status); |
| 7669 | } |
| 7670 | |
| 7671 | return deserialize<v1::master::Response>( |
| 7672 | ContentType::PROTOBUF, response.body); |
| 7673 | }); |
| 7674 | } |
| 7675 | |
| 7676 | |
| 7677 | // This is a regression test for MESOS-9609. |
no test coverage detected