Unverified Commit b1596695 authored by Kip's avatar Kip Committed by GitHub

Merge pull request #1023 from tn-jed/add-test-ChunkedStream-disconnect

Add test demonstrating server crash in issue #1007
parents d1d23400 ede8503c
......@@ -267,3 +267,46 @@ TEST_F(StreamingTests, ChunkedStream)
EXPECT_EQ(chunks[1], "world");
EXPECT_EQ(chunks[2], "!");
}
TEST_F(StreamingTests, ChunkedStreamDisconnect)
{
SyncContext ctx;
// force unbuffered
curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 1);
Init(std::make_shared<HelloHandler>(ctx));
std::thread thread([&]() {
CURLM *multi_handle;
int still_running = 1;
multi_handle = curl_multi_init();
curl_multi_add_handle(multi_handle, curl);
// This sequence of _perform, _poll, _perform starts a requests (all 3 are needed)
curl_multi_perform(multi_handle, &still_running);
if(still_running){
curl_multi_poll(multi_handle, NULL, 0, 1000, NULL);
curl_multi_perform(multi_handle, &still_running);
}
std::this_thread::sleep_for(std::chrono::milliseconds(200));
// Hard-close the client request & socket before server is done responding
curl_multi_cleanup(multi_handle);
});
std::unique_lock<std::mutex> lk { ctx.m };
ctx.cv.wait(lk, [&ctx] { return ctx.flag; });
//Bad behavior might take a few seconds...
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
if (thread.joinable())
{
thread.join();
}
// Don't care about response content, this test will fail if SIGINT is raised
}
\ No newline at end of file
0.0.3.20211030
0.0.3.20220107
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment