mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-03 04:17:52 +08:00
34 lines
950 B
C++
34 lines
950 B
C++
#include <list>
|
|
#include "acl_cpp/lib_acl.hpp"
|
|
|
|
using namespace acl;
|
|
|
|
int main(void)
|
|
{
|
|
const char* data = "U_TRS1=000000f6.66721803.4fd1681c.8c48b73a; path=/; expires=Mon, 06-Jun-22 02:49:00 GMT; domain=.sina.com.cn";
|
|
HttpCookie* cookie = new HttpCookie();
|
|
|
|
printf("Set-Cookie: %s\r\n", data);
|
|
|
|
if (cookie->setCookie(data) == false)
|
|
{
|
|
printf("parse cookie(%s) error\r\n", data);
|
|
cookie->destroy();
|
|
return -1;
|
|
}
|
|
|
|
printf("cookie name: %s\r\n", cookie->getName());
|
|
printf("cookie value: %s\r\n", cookie->getValue());
|
|
printf("domain: %s\r\n", cookie->getDomain());
|
|
printf("path: %s\r\n", cookie->getPath());
|
|
printf("max-age: %d\r\n", cookie->getMaxAge());
|
|
|
|
const std::list<HTTP_PARAM*>& params = cookie->getParams();
|
|
std::list<HTTP_PARAM*>::const_iterator cit = params.begin();
|
|
for (; cit != params.end(); ++cit)
|
|
printf(">>%s=%s\r\n", (*cit)->name, (*cit)->value);
|
|
|
|
cookie->destroy();
|
|
return 0;
|
|
}
|