winhttp 协议头中取出cookie

CString GetCookieString(CString& strRspHeader)
{
CString retCookie, strKey = _T("Set-Cookie: ");
int iBegin = 0, iEnd = 0;
while(iBegin < strRspHeader.GetLength())
{
iBegin = strRspHeader.Find(strKey, iBegin);
if (iBegin >= 0)
{
iEnd = strRspHeader.Find(_T("\r\n"), iBegin);
if (iEnd > 0)
{
retCookie += strRspHeader.Mid(iBegin, iEnd-iBegin+2);
iBegin = iEnd;
}
}else{
break;
}
}

return retCookie;
}

posted @ 2016-03-24 20:05  夜的黑=?  阅读(711)  评论(0编辑  收藏  举报