Added chunked transfer tests
This commit is contained in:
parent
4f67773a25
commit
c126eb76b9
1 changed files with 12 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue