diff --git a/tests/io_test.cpp b/tests/io_test.cpp index f1bc4e93..66b0e39e 100644 --- a/tests/io_test.cpp +++ b/tests/io_test.cpp @@ -124,6 +124,14 @@ int main() { response->write(request->query_string); }; + server.resource["^/chunked$"]["POST"] = [](shared_ptr response, shared_ptr request) { + assert(request->path == "/chunked"); + + assert(request->content.string() == "SimpleWeb in\r\n\r\nchunks."); + + response->write("6\r\nSimple\r\n3\r\nWeb\r\nE\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n", {{"Transfer-Encoding", "chunked"}}); + }; + thread server_thread([&server]() { // Start server server.start(); @@ -153,7 +161,6 @@ int main() { } { - stringstream output; auto r = client.request("POST", "/string", "A string"); assert(SimpleWeb::status_code(r->status_code) == SimpleWeb::StatusCode::success_ok); assert(r->content.string() == "A string"); @@ -208,6 +215,10 @@ int main() { output << r->content.rdbuf(); assert(output.str() == "123"); } + { + auto r = client.request("POST", "/chunked", "6\r\nSimple\r\n3\r\nWeb\r\nE\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n", {{"Transfer-Encoding", "chunked"}}); + assert(r->content.string() == "SimpleWeb in\r\n\r\nchunks."); + } } { HttpClient client("localhost:8080");