From 39fbcf7dadd15988af79bdd531b64cb91ca670bc Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Wed, 1 May 2024 21:34:39 -0400 Subject: [PATCH] post --- src/database.cc | 12 ++++-------- src/database.hh | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/database.cc b/src/database.cc index 6d05474..35d2468 100644 --- a/src/database.cc +++ b/src/database.cc @@ -1,6 +1,6 @@ #include "database.hh" - +#include #include "noidb.hh" seastar::future Database::stop() { @@ -18,12 +18,8 @@ future Database::put(const sstring& key, sstring& val) { co_return true; } -future Database::post(const sstring& key, input_stream* stream) { - sstring val; - while (auto buf = co_await stream->read()) { - val.append(buf.get(), buf.size()); - } - lg.info("post: {} -> {}", key, val); +future Database::post(const sstring& key, sstring& val, size_t bytes) { + lg.info("post: {} -> {} {}", key, bytes, val); co_return true; } @@ -59,7 +55,7 @@ PostHandler::PostHandler(Database& db) future> PostHandler::handle(const sstring& path, std::unique_ptr req, std::unique_ptr rep) { sstring rest = req->param.get_decoded_param("path"); - rep->write_body("json", json::stream_object(co_await db.post(rest, req->content_stream))); + rep->write_body("json", json::stream_object(co_await db.post(rest, req->content, req->content_length))); co_return std::move(rep); } diff --git a/src/database.hh b/src/database.hh index db620bc..d3e6b71 100644 --- a/src/database.hh +++ b/src/database.hh @@ -13,7 +13,7 @@ public: future stop(); future get(const sstring& key); future put(const sstring& key, sstring& val); - future post(const sstring& key, input_stream* val); + future post(const sstring& key, sstring& val, size_t bytes); future del(const sstring& key); };