diff --git a/src/server/http_api.cc b/src/server/http_api.cc index 9e6b5c9b55b5..1d74b92ec0df 100644 --- a/src/server/http_api.cc +++ b/src/server/http_api.cc @@ -124,7 +124,7 @@ struct CaptureVisitor { } void operator()(CapturingReplyBuilder::Error err) { - str = absl::StrCat(R"({"error": ")", err.first); + str = absl::StrCat(R"({"error": ")", err.first, "\""); } void operator()(facade::OpStatus status) { @@ -132,7 +132,13 @@ struct CaptureVisitor { } void operator()(const CapturingReplyBuilder::StrArrPayload& sa) { - absl::StrAppend(&str, "not_implemented"); + absl::StrAppend(&str, "["); + for (const auto& val : sa.arr) { + absl::StrAppend(&str, JsonEscape(val), ","); + } + if (sa.arr.size()) + str.pop_back(); + absl::StrAppend(&str, "]"); } void operator()(unique_ptr cp) { @@ -152,7 +158,18 @@ struct CaptureVisitor { } void operator()(facade::SinkReplyBuilder::MGetResponse resp) { - absl::StrAppend(&str, "not_implemented"); + absl::StrAppend(&str, "["); + for (const auto& val : resp.resp_arr) { + if (val) { + absl::StrAppend(&str, JsonEscape(val->value), ","); + } else { + absl::StrAppend(&str, "null,"); + } + } + + if (resp.resp_arr.size()) + str.pop_back(); + absl::StrAppend(&str, "]"); } void operator()(const CapturingReplyBuilder::ScoredArray& sarr) { diff --git a/tests/dragonfly/connection_test.py b/tests/dragonfly/connection_test.py index 3c15f5479517..c4285b567301 100755 --- a/tests/dragonfly/connection_test.py +++ b/tests/dragonfly/connection_test.py @@ -766,4 +766,11 @@ async def test_http(df_server: DflyInstance): assert resp.status == 200 text = await resp.text() assert text.strip() == '{"result":"МайяХилли"}' + + body = '["foo", "bar"]' + async with session.post(f"http://localhost:{df_server.port}/api", data=body) as resp: + assert resp.status == 200 + text = await resp.text() + assert text.strip() == '{"error": "unknown command `FOO`"}' + assert await client.ttl("foo") > 0