本文整理汇总了C++中poco::net::HTTPServerRequest::getCookies方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPServerRequest::getCookies方法的具体用法?C++ HTTPServerRequest::getCookies怎么用?C++ HTTPServerRequest::getCookies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::net::HTTPServerRequest
的用法示例。
在下文中一共展示了HTTPServerRequest::getCookies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: destroySession
void BaseSessionStore::destroySession(Poco::Net::HTTPServerRequest& request,
Poco::Net::HTTPServerResponse& response)
{
// Get the cookies from the client.
Poco::Net::NameValueCollection cookies;
// Get the cookies
request.getCookies(cookies);
// Try to find a cookie with our session key name.
Poco::Net::NameValueCollection::ConstIterator cookieIter = cookies.begin();
while (cookieIter != cookies.end())
{
if (0 == cookieIter->first.compare(_sessionKeyName))
{
// Destroy the session data.
destroySession(cookieIter->second);
// Invalidate the cookies.
Poco::Net::HTTPCookie cookie(_sessionKeyName, cookieIter->second);
cookie.setMaxAge(0);
response.addCookie(cookie);
}
++cookieIter;
}
}
示例2: str
void Susi::WebSocketRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request,
Poco::Net::HTTPServerResponse& response) {
Poco::Net::WebSocket socket(request,response);
Poco::Net::NameValueCollection cookies;
request.getCookies(cookies);
std::string id = cookies["susisession"];
Susi::Logger::debug("register sender in ws");
apiServer->registerSender(id,[&socket](Susi::Util::Any & arg){
std::string msg = arg.toString();
Susi::Logger::debug("send frame to websocket");
socket.sendFrame(msg.data(), msg.length(), Poco::Net::WebSocket::FRAME_TEXT);
});
apiServer->onConnect(id);
char buffer[4096];
int flags;
size_t n;
while (true) {
n = socket.receiveFrame(buffer, sizeof(buffer), flags);
Susi::Logger::debug("got frame");
Susi::Logger::debug(std::to_string(n));
if(n==0 || (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE){
break;
}
std::string str(buffer, n);
Susi::Util::Any packet = Susi::Util::Any::fromString(str);
apiServer->onMessage(id,packet);
}
Susi::Logger::debug("closing websocket");
apiServer->onClose(id);
}
示例3: getId
std::string WebSessionManager::getId(const std::string& appName, const Poco::Net::HTTPServerRequest& request)
{
std::string id;
std::string name(cookieName(appName));
NameValueCollection cookies;
request.getCookies(cookies);
NameValueCollection::ConstIterator it = cookies.find(name);
if (it != cookies.end())
id = it->second;
return id;
}