mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-21 20:28:30 +00:00
Fixed #28. (Keep-Alive connection support)
This commit is contained in:
parent
ca7b942196
commit
23c8f0c738
4 changed files with 263 additions and 122 deletions
test
20
test/test.cc
20
test/test.cc
|
@ -139,11 +139,12 @@ TEST(GetHeaderValueTest, Range)
|
|||
void testChunkedEncoding(httplib::HttpVersion ver)
|
||||
{
|
||||
auto host = "www.httpwatch.com";
|
||||
auto port = 80;
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
auto port = 443;
|
||||
httplib::SSLClient cli(host, port, ver);
|
||||
#else
|
||||
auto port = 80;
|
||||
httplib::Client cli(host, port, ver);
|
||||
#endif
|
||||
|
||||
|
@ -166,11 +167,12 @@ TEST(ChunkedEncodingTest, FromHTTPWatch)
|
|||
TEST(RangeTest, FromHTTPBin)
|
||||
{
|
||||
auto host = "httpbin.org";
|
||||
auto port = 80;
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
auto port = 443;
|
||||
httplib::SSLClient cli(host, port, httplib::HttpVersion::v1_1);
|
||||
#else
|
||||
auto port = 80;
|
||||
httplib::Client cli(host, port, httplib::HttpVersion::v1_1);
|
||||
#endif
|
||||
|
||||
|
@ -265,27 +267,23 @@ protected:
|
|||
EXPECT_EQ("application/octet-stream", file.content_type);
|
||||
EXPECT_EQ(0u, file.length);
|
||||
}
|
||||
})
|
||||
.get("/stop", [&](const Request& /*req*/, Response& /*res*/) {
|
||||
svr_.stop();
|
||||
});
|
||||
|
||||
persons_["john"] = "programmer";
|
||||
|
||||
f_ = async([&](){
|
||||
t_ = thread([&](){
|
||||
up_ = true;
|
||||
svr_.listen(HOST, PORT);
|
||||
});
|
||||
|
||||
while (!up_) {
|
||||
while (!svr_.is_running()) {
|
||||
msleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
//svr_.stop(); // NOTE: This causes dead lock on Windows.
|
||||
cli_.get("/stop");
|
||||
f_.get();
|
||||
svr_.stop();
|
||||
t_.join();
|
||||
}
|
||||
|
||||
map<string, string> persons_;
|
||||
|
@ -296,7 +294,7 @@ protected:
|
|||
Client cli_;
|
||||
Server svr_;
|
||||
#endif
|
||||
future<void> f_;
|
||||
thread t_;
|
||||
bool up_;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue