从winhttp标头中检索多个cookie

时间:2015-07-06 05:23:50

标签: c++ winhttp

我想从winhttpheader中检索cookie。问题是标题是这种形式:

Header-Contents
Transfer-Encoding: chunked
Server: nginx
Set-Cookie: name=xyz; Path=/
; secure; httponly
Set-Cookie: token=45e8e18440859e769a56b0e1191bea8f1cc049d1; Path=/
; secure; httponly

现在使用winhttp_query_set_cookie,我只获取名称字段,而不是令牌。

  do
   {
           bQuerySizeResult=WinHttpQueryHeaders(hRequest,WINHTTP_QUERY_SET_COOKIE,WINHTTP_HEADER_NAME_BY_INDEX,NULL,&nCookie,WINHTTP_NO_HEADER_INDEX);
        WCHAR *strCookie=new WCHAR[nCookie];
         LPCTSTR ws1;
              bQuerySizeResult=WinHttpQueryHeaders(hRequest,WINHTTP_QUERY_SET_COOKIE,WINHTTP_HEADER_NAME_BY_INDEX,strCookie,&nCookie,WINHTTP_NO_HEADER_INDEX);

        std::wcout<<"\n" <<strCookie[0]<<" "<<strCookie[1];
        ws1=strCookie;
        std::wstring  ws(ws1);
        std::string str(ws.begin(), ws.end());
        LPSTR mystring ;
        mystring= const_cast<LPSTR>(str.c_str());
      std::cout<<"\nthe str is "<<mystring<<"\n";
}while(bQuerySizeResult);*/

0 个答案:

没有答案