Related to #246 : added test where multiple clients sends posts concurrently to a server
This commit is contained in:
parent
3fcf628657
commit
1f699fc304
1 changed files with 21 additions and 0 deletions
|
|
@ -317,6 +317,27 @@ int main() {
|
|||
for(auto call : calls)
|
||||
ASSERT(call);
|
||||
}
|
||||
|
||||
// Test concurrent requests from different clients
|
||||
{
|
||||
vector<int> calls(10, 0);
|
||||
vector<thread> threads;
|
||||
for(size_t c = 0; c < 10; ++c) {
|
||||
threads.emplace_back([c, &calls] {
|
||||
HttpClient client("localhost:8080");
|
||||
client.request("POST", "/string", "A string", [c, &calls](shared_ptr<HttpClient::Response> response, const SimpleWeb::error_code &ec) {
|
||||
ASSERT(!ec);
|
||||
ASSERT(response->content.string() == "A string");
|
||||
calls[c] = 1;
|
||||
});
|
||||
client.io_service->run();
|
||||
});
|
||||
}
|
||||
for(auto &thread : threads)
|
||||
thread.join();
|
||||
for(auto call : calls)
|
||||
ASSERT(call);
|
||||
}
|
||||
}
|
||||
|
||||
// Test concurrent synchronous request calls
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue