diff options
author | ipknHama <ipknhama@gmail.com> | 2014-09-14 08:16:49 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2014-09-14 08:16:49 +0900 |
commit | 6ee8bd992e6719d3cba7a0dba15602ea7060f022 (patch) | |
tree | 66d0355462de0430cc50a8edaea617cc3e6b3e8b /tests | |
parent | fe4f9340330627106bde7d05562f08655e6bb08e (diff) | |
download | crow-6ee8bd992e6719d3cba7a0dba15602ea7060f022.tar.gz crow-6ee8bd992e6719d3cba7a0dba15602ea7060f022.zip |
added test case for handling repeated request wrong
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittest.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/unittest.cpp b/tests/unittest.cpp index 41387fa..b552ddc 100644 --- a/tests/unittest.cpp +++ b/tests/unittest.cpp @@ -717,6 +717,44 @@ TEST(middleware_cookieparser) server.stop(); } +TEST(bug_quick_repeated_request) +{ + static char buf[2048]; + + SimpleApp app; + + CROW_ROUTE(app, "/")([&]{ + return "hello"; + }); + + decltype(app)::server_t server(&app, 45451); + auto _ = async(launch::async, [&]{server.run();}); + std::string sendmsg = "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n"; + asio::io_service is; + { + std::vector<std::future<void>> v; + for(int i = 0; i < 5; i++) + { + v.push_back(async(launch::async, + [&] + { + asio::ip::tcp::socket c(is); + c.connect(asio::ip::tcp::endpoint(asio::ip::address::from_string("127.0.0.1"), 45451)); + + for(int j = 0; j < 5; j ++) + { + c.send(asio::buffer(sendmsg)); + + size_t received = c.receive(asio::buffer(buf, 2048)); + ASSERT_EQUAL("hello", std::string(buf + received - 5, buf + received)); + } + c.close(); + })); + } + } + server.stop(); +} + int main() { return testmain(); |