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

Commit c126eb7

Browse files
committed
Added chunked transfer tests
1 parent 4f67773 commit c126eb7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/io_test.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ int main() {
124124
response->write(request->query_string);
125125
};
126126

127+
server.resource["^/chunked$"]["POST"] = [](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {
128+
assert(request->path == "/chunked");
129+
130+
assert(request->content.string() == "SimpleWeb in\r\n\r\nchunks.");
131+
132+
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"}});
133+
};
134+
127135
thread server_thread([&server]() {
128136
// Start server
129137
server.start();
@@ -153,7 +161,6 @@ int main() {
153161
}
154162

155163
{
156-
stringstream output;
157164
auto r = client.request("POST", "/string", "A string");
158165
assert(SimpleWeb::status_code(r->status_code) == SimpleWeb::StatusCode::success_ok);
159166
assert(r->content.string() == "A string");
@@ -208,6 +215,10 @@ int main() {
208215
output << r->content.rdbuf();
209216
assert(output.str() == "123");
210217
}
218+
{
219+
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"}});
220+
assert(r->content.string() == "SimpleWeb in\r\n\r\nchunks.");
221+
}
211222
}
212223
{
213224
HttpClient client("localhost:8080");

0 commit comments

Comments
 (0)