Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Added chunked transfer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eidheim committed Nov 19, 2017
1 parent 4f67773 commit c126eb7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/io_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ int main() {
response->write(request->query_string);
};

server.resource["^/chunked$"]["POST"] = [](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> 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();
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit c126eb7

Please sign in to comment.