diff --git a/CHN-07-会话.md b/CHN-07-会话.md index 3a8bbdb..3457cc7 100644 --- a/CHN-07-会话.md +++ b/CHN-07-会话.md @@ -2,7 +2,7 @@ ```c++ void disableSession(); - void enableSession(const size_t timeout=0); + void enableSession(const size_t timeout=0, Cookie::SameSite sameSite=Cooie::SameSite::kNull); ``` 都是通过`HttpAppFramework`单例调用,timeout参数代表了会话失效的时间,单位是秒,框架默认值是1200,即如果用户20分钟以上没有访问应用,则他对应的会话就失效了。timeout设置为0表示drogon将在整个生存期保留用户的会话; @@ -95,4 +95,4 @@ drogon::HttpAppFramework::instance().enableSession(1200); 用cmake重新编译整个工程,运行目标程序webapp,就可以通过浏览器看到效果了。 -# [数据库](CHN-08-0-数据库-概述) \ No newline at end of file +# [数据库](CHN-08-0-数据库-概述) diff --git a/CHN-18-测试框架.md b/CHN-18-测试框架.md index 08cdeb5..73d6634 100644 --- a/CHN-18-测试框架.md +++ b/CHN-18-测试框架.md @@ -101,9 +101,9 @@ Drogon 是一个异步网站框架。 它仅遵循因此 DrogonTest 支持测试 DROGON_TEST(RemoteAPITest) { auto client = HttpClient::newHttpClient("http://localhost:8848"); - auto req = HttpReuqest::newHttpRequest(); + auto req = HttpRequest::newHttpRequest(); req->setPath("/"); - client->sendRequest(req, [TEST_CTX](ReqResuelt res, const HttpResponsePtr& resp) { + client->sendRequest(req, [TEST_CTX](ReqResult res, const HttpResponsePtr& resp) { // There's nothing we can do if the request didn't reach the server // or the server generated garbage. REQUIRE(res == ReqResult::Ok); @@ -122,7 +122,7 @@ DROGON_TEST(RemoteAPITestCoro) { auto api_test = [TEST_CTX]() { auto client = HttpClient::newHttpClient("http://localhost:8848"); - auto req = HttpReuqest::newHttpRequest(); + auto req = HttpRequest::newHttpRequest(); req->setPath("/"); auto resp = co_await client->sendRequestCoro(req); diff --git a/ENG-07-Session.md b/ENG-07-Session.md index 7236d48..2681a89 100644 --- a/ENG-07-Session.md +++ b/ENG-07-Session.md @@ -2,11 +2,11 @@ ```c++ void disableSession(); - void enableSession(const size_t timeout=0); + void enableSession(const size_t timeout=0, Cookie::SameSite sameSite=Cooie::SameSite::kNull); ``` The above methods are all called through the `HttpAppFramework` singleton. The timeout parameter represents the time when the session is invalid. The unit is second. The default value is 1200. That is, if the user does not access the web application for more than 20 minutes, the corresponding session will be invalid. Setting timeout to 0 means that drogon will retain the user's session for the entire lifetime; - +The sameSite parameter changes the SameSite attribute of the Set-Cookie HTTP response header. Make sure your client supports cookies before opening the session feature. Otherwise, drogon will create a new session for each request without `SessionID` cookie, which will waste memory and computing resources. @@ -95,4 +95,4 @@ drogon::HttpAppFramework::instance().enableSession(1200); Recompile the entire project with cmake, run the target program webapp, and you can see the effect through the browser. -# 08.0 [Database](ENG-08-0-Database-General) \ No newline at end of file +# 08.0 [Database](ENG-08-0-Database-General) diff --git a/ENG-18-Testing-Framework.md b/ENG-18-Testing-Framework.md index b9e6568..d1ce0b5 100644 --- a/ENG-18-Testing-Framework.md +++ b/ENG-18-Testing-Framework.md @@ -101,9 +101,9 @@ Drogon is a asynchronous web framework. It only follows DrogonTest supports test DROGON_TEST(RemoteAPITest) { auto client = HttpClient::newHttpClient("http://localhost:8848"); - auto req = HttpReuqest::newHttpRequest(); + auto req = HttpRequest::newHttpRequest(); req->setPath("/"); - client->sendRequest(req, [TEST_CTX](ReqResuelt res, const HttpResponsePtr& resp) { + client->sendRequest(req, [TEST_CTX](ReqResult res, const HttpResponsePtr& resp) { // There's nothing we can do if the request didn't reach the server // or the server generated garbage. REQUIRE(res == ReqResult::Ok); @@ -122,7 +122,7 @@ DROGON_TEST(RemoteAPITestCoro) { auto api_test = [TEST_CTX]() { auto client = HttpClient::newHttpClient("http://localhost:8848"); - auto req = HttpReuqest::newHttpRequest(); + auto req = HttpRequest::newHttpRequest(); req->setPath("/"); auto resp = co_await client->sendRequestCoro(req);