internal static void OnSendingHeaders(HttpWebRequest httpWebRequest) {
GlobalLog.Print("CookieModule::OnSendingHeaders()");
try {
if (httpWebRequest.CookieContainer == null) {
return;
}
//
// remove all current cookies. This could be a redirect
//
httpWebRequest.Headers.RemoveInternal(HttpKnownHeaderNames.Cookie);
//
// add in the new headers from the cookie container for this request
//
string optCookie2;
string cookieString = httpWebRequest.CookieContainer.GetCookieHeader(
httpWebRequest.Address,
out optCookie2);
if (cookieString.Length > 0) {
GlobalLog.Print("CookieModule::OnSendingHeaders() setting Cookie header to:[" + cookieString + "]");
httpWebRequest.Headers[HttpKnownHeaderNames.Cookie] = cookieString;
}
}
catch {
}
}