MCPcopy Create free account
hub / github.com/acl-dev/acl / setCookie

Method setCookie

lib_acl_cpp/src/http/HttpCookie.cpp:131–171  ·  view source on GitHub ↗

value ��ʽ��xxx=xxx; domain=xxx; expires=xxx; path=xxx

Source from the content-addressed store, hash-verified

129
130// value ��ʽ��xxx=xxx; domain=xxx; expires=xxx; path=xxx
131bool HttpCookie::setCookie(const char* value)
132{
133 if (value == NULL || *value == 0) {
134 return false;
135 }
136
137 ACL_ARGV* tokens = acl_argv_split(value, ";");
138 acl_assert(tokens->argc > 0);
139
140 HTTP_PARAM param;
141
142 // �ӵ�һ�� name=value �ֶ���ȡ�� cookie ���� cookie ֵ
143 if (splitNameValue(tokens->argv[0], &param) == false) {
144 acl_argv_free(tokens);
145 return false;
146 }
147 // name �϶��� "\0"���� value ����Ϊ "\0"
148 name_ = dbuf_->dbuf_strdup(param.name);
149 value_ = dbuf_->dbuf_strdup(param.value);
150
151 for (int i = 1; i < tokens->argc; i++) {
152 if (splitNameValue(tokens->argv[i], &param) == false) {
153 continue;
154 }
155 if (*(param.value) == 0) {
156 continue;
157 }
158 if (strcasecmp(param.name, "domain") == 0) {
159 setDomain(param.value);
160 } else if (strcasecmp(param.name, "expires") == 0) {
161 setExpires(param.value);
162 } else if (strcasecmp(param.name, "path") == 0) {
163 setPath(param.value);
164 } else {
165 add(param.name, param.value);
166 }
167 }
168
169 acl_argv_free(tokens);
170 return true;
171}
172
173HttpCookie& HttpCookie::setDomain(const char* domain)
174{

Callers 3

mainFunction · 0.45
create_cookiesMethod · 0.45
add_res_cookieMethod · 0.45

Calls 3

acl_argv_splitFunction · 0.85
acl_argv_freeFunction · 0.85
dbuf_strdupMethod · 0.80

Tested by

no test coverage detected