| 1035 | } |
| 1036 | |
| 1037 | void http_request::create_cookies() |
| 1038 | { |
| 1039 | acl_assert(cookie_inited_ == false); |
| 1040 | if (client_ == NULL) { |
| 1041 | logger_error("connection not opened yet"); |
| 1042 | return; |
| 1043 | } |
| 1044 | |
| 1045 | const HTTP_HDR_RES* res = client_->get_respond_head(NULL); |
| 1046 | if (res == NULL) { |
| 1047 | return; |
| 1048 | } |
| 1049 | |
| 1050 | if (cookies_ == NULL) { |
| 1051 | cookies_ = NEW std::vector<HttpCookie*>; |
| 1052 | } |
| 1053 | |
| 1054 | int n = acl_array_size(res->hdr.entry_lnk); |
| 1055 | for (int i = 0; i < n; i++) { |
| 1056 | const HTTP_HDR_ENTRY* hdr = (const HTTP_HDR_ENTRY*) |
| 1057 | acl_array_index(res->hdr.entry_lnk, i); |
| 1058 | if (strcasecmp(hdr->name, "Set-Cookie") != 0) |
| 1059 | continue; |
| 1060 | if (hdr->value == NULL || *(hdr->value) == 0) |
| 1061 | continue; |
| 1062 | HttpCookie* cookie = NEW HttpCookie(); |
| 1063 | if (! cookie->setCookie(hdr->value)) { |
| 1064 | cookie->destroy(); |
| 1065 | continue; |
| 1066 | } |
| 1067 | cookies_->push_back(cookie); |
| 1068 | } |
| 1069 | |
| 1070 | cookie_inited_ = true; |
| 1071 | } |
| 1072 | |
| 1073 | } // namespace acl |
no test coverage detected