Newsgroups : Microsoft : microsoft.public.inetsdk.programming.wininet : 2005 Apr : INTERNET_STATUS_REDIRECT with Set-Cookie

www.cryer.info
Managed Newsgroup Archive

INTERNET_STATUS_REDIRECT with Set-Cookie

Subject:INTERNET_STATUS_REDIRECT with Set-Cookie
Posted by:"maxixi" (greenxi..@hotmail.com)
Date:Thu, 14 Apr 2005 01:10:12

Hi,

How to redirect request with extra cookies?
My request flag is INTERNET_FLAG_NO_COOKIES.
In the redirecting process i parsed the
"Set-Cookie" headers and save it to a
CookieContainer. I need to add the "Cookie"
in the new redirecting resource, How can i do?

private void StatusCallback(
IntPtr m_hHandle,
UInt32 dwContext,
WinInet.INTERNET_STATUS dwInternetStatus,
IntPtr lpvStatusInformation,
UInt32 dwStatusInformationLength)
{
case WinInet.INTERNET_STATUS.INTERNET_STATUS_REDIRECT:
  m_nRedirectTimes++;
  if (m_nRedirectTimes > m_nMaximumAutomaticRedirections) {
    m_eStatus = RequestStatus.RedirectError;
    m_eErrorEvent.Set();
  }
  else {
   string str = Marshal.PtrToStringAnsi(lpvStatusInformation,
(int)dwStatusInformationLength - 1);
   m_sResponseUri = new System.Uri(str);

   string[] ss = WinInet.HttpQueryInfoStrings(m_hRequest,
WinInet.HTTP_QUERY.HTTP_QUERY_SET_COOKIE);
   foreach(string st in ss) {
    System.Net.Cookie c = Util.SetCookieParser(st);
    if (c != null) m_pClient.m_oCookieContainer.Add(c);
  }
}
}

Maxixi

Replies:

www.cryer.info
Managed Newsgroup Archive