예제 #1
0
void MonitorSink::ExportCookies(LPCWSTR szResponseHeaders)
{
    static const WCHAR SET_COOKIE_HEAD [] = L"\r\nSet-Cookie:";

    std::vector<UserMessage::SetFirefoxCookieParams> vCookieParams;
    LPWSTR p = (LPWSTR)szResponseHeaders;
    LPWSTR lpCookies = NULL;
    size_t nCookieLen = 0;
    while (p = Utils::HTTP::ExtractFieldValue(p, SET_COOKIE_HEAD, &lpCookies, & nCookieLen))
    {
        if (lpCookies)
        {
            CString strURL = GetBindURL();
            CString strCookie((LPCTSTR)CW2T(lpCookies));
            Utils::HTTP::FreeFieldValue(lpCookies);
            lpCookies = NULL;

            UserMessage::SetFirefoxCookieParams cookieParam;
            cookieParam.strURL = strURL;
            cookieParam.strCookie = strCookie;
            vCookieParams.push_back(cookieParam);
            TRACE(_T("[ExportCookies] URL: %s  Cookie: %s\n"), strURL, strCookie);
            nCookieLen = 0;
        }
    }
    if (vCookieParams.size())
        CIEHostWindow::SetFirefoxCookie(std::move(vCookieParams), m_pIEHostWindow);
}
예제 #2
0
void nsBrowserListener::SetCookie(const nsCString &cookie)
{
     nsCOMPtr<nsIURI> cookieUri(nsnull);
     iio->NewURI(aurl,nsnull,nsnull,getter_AddRefs(cookieUri));
     if (cookieUri==nsnull)
     {
	  return;
     }
     std::string strCookie(cookie.get());
     size_t index=0;
     do
     {
	  size_t curr=index;
	  index=strCookie.find(";",curr);
	  if(index!=std::string::npos)
	  {
	       index++;
	       std::string tmpCook=strCookie.substr(curr,index-curr);
	       LOG<<"tmpcook:"<<tmpCook<<"\n";
	       cookServ->SetCookieString(cookieUri, nsnull, tmpCook.c_str(), nsnull);
	  }
     }while(index!=std::string::npos);
}