修改cookie设置的bug

This commit is contained in:
xiongziliang 2018-09-25 09:26:23 +08:00
parent 8e4a2f25ba
commit 92d35f885a

View File

@ -247,15 +247,23 @@ void HttpClient::checkCookie(HttpClient::HttpHeader &headers) {
HttpCookie::Ptr cookie = std::make_shared<HttpCookie>(); HttpCookie::Ptr cookie = std::make_shared<HttpCookie>();
cookie->setHost(_lastHost); cookie->setHost(_lastHost);
for(auto &pr : key_val){ int index = 0;
if(pr.first == "path"){ auto arg_vec = split(set_cookie, ";");
cookie->setPath(pr.second); for (string &key_val : arg_vec) {
}else if(pr.first == "expires"){ auto key = FindField(key_val.data(),NULL,"=");
cookie->setExpires(pr.second); auto val = FindField(key_val.data(),"=", NULL);
}else{
cookie->setKeyVal(pr.first,pr.second); if(index++ == 0){
cookie->setKeyVal(key,val);
} else{
if(key == "path"){
cookie->setPath(val);
}else if(key == "expires"){
cookie->setExpires(val);
}
} }
} }
if(!(*cookie)){ if(!(*cookie)){
//无效的cookie //无效的cookie
return; return;