Discussion:
INTERNET_STATUS_REDIRECT with Set-Cookie
(too old to reply)
maxixi
2005-04-13 17:10:12 UTC
Permalink
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
Stephen Sulzer
2005-04-19 01:46:19 UTC
Permalink
Within the INTERNET_STATUS_REDIRECT callback, after you collect the cookies
from the Set-Cookie response header, you can (try to) add the Cookie headers
using HttpAddRequestHeaders.

- Stephen

Continue reading on narkive:
Loading...