Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / _CookieModule.cs / 1 / _CookieModule.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net { internal static class CookieModule { // fields // constructors // properties // methods 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 { } } internal static void OnReceivedHeaders(HttpWebRequest httpWebRequest) { GlobalLog.Print("CookieModule.OnReceivedHeaders()"); // // if the app doesn't want us to handle cookies then there's nothing // to do. Note that we're leaving open the possibility that these // settings could be changed between the request being made and the // response received // try { if (httpWebRequest.CookieContainer == null) { return; } // // add any received cookies for this response to the container // HttpWebResponse response = httpWebRequest._HttpResponse as HttpWebResponse; if (response == null) { return; } CookieCollection cookies = null; try { string cookieString = response.Headers.SetCookie; GlobalLog.Print("CookieModule::OnSendingHeaders() received Set-Cookie:[" + cookieString + "]"); if ((cookieString != null) && (cookieString.Length > 0)) { cookies = httpWebRequest.CookieContainer.CookieCutter( response.ResponseUri, HttpKnownHeaderNames.SetCookie, cookieString, false); } } catch { } try { string cookieString = response.Headers.SetCookie2; GlobalLog.Print("CookieModule::OnSendingHeaders() received Set-Cookie2:[" + cookieString + "]"); if ((cookieString != null) && (cookieString.Length > 0)) { CookieCollection cookies2 = httpWebRequest.CookieContainer.CookieCutter( response.ResponseUri, HttpKnownHeaderNames.SetCookie2, cookieString, false); if (cookies != null && cookies.Count != 0) { cookies.Add(cookies2); } else { cookies = cookies2; } } } catch { } if (cookies != null) { response.Cookies = cookies; } } catch { } } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Win32.cs
- UrlParameterWriter.cs
- XmlSchemaChoice.cs
- DataPagerFieldCommandEventArgs.cs
- TraceInternal.cs
- Line.cs
- SharedPersonalizationStateInfo.cs
- WebPartVerbsEventArgs.cs
- RegistrationServices.cs
- TemplateColumn.cs
- RootBuilder.cs
- SHA512Managed.cs
- As.cs
- DbBuffer.cs
- TrackBar.cs
- EncryptedKeyHashIdentifierClause.cs
- RequestCachePolicy.cs
- EncoderNLS.cs
- LocationUpdates.cs
- GridProviderWrapper.cs
- FacetChecker.cs
- PageParser.cs
- StickyNote.cs
- PathFigure.cs
- httpserverutility.cs
- StorageTypeMapping.cs
- _SingleItemRequestCache.cs
- ArglessEventHandlerProxy.cs
- CompareValidator.cs
- Util.cs
- UserControlParser.cs
- HttpCapabilitiesBase.cs
- ResourceDisplayNameAttribute.cs
- XPathNodeHelper.cs
- ToolStripButton.cs
- TypeUnloadedException.cs
- EventOpcode.cs
- MsmqHostedTransportConfiguration.cs
- webproxy.cs
- GenericAuthenticationEventArgs.cs
- DataServiceRequestException.cs
- PageParser.cs
- MetadataUtilsSmi.cs
- IPEndPointCollection.cs
- DrawingState.cs
- Identifier.cs
- C14NUtil.cs
- BinaryMethodMessage.cs
- SettingsPropertyValue.cs
- FontDifferentiator.cs
- CharEnumerator.cs
- FormViewPageEventArgs.cs
- TextRangeAdaptor.cs
- FixedSOMTextRun.cs
- TextTrailingCharacterEllipsis.cs
- DataGridViewCellStyleEditor.cs
- ResourcesBuildProvider.cs
- Processor.cs
- DesignerVerbCollection.cs
- FixedStringLookup.cs
- Blend.cs
- TranslateTransform3D.cs
- CapacityStreamGeometryContext.cs
- EpmCustomContentSerializer.cs
- Converter.cs
- UserControl.cs
- DiffuseMaterial.cs
- CompilerErrorCollection.cs
- SqlCachedBuffer.cs
- HTTPNotFoundHandler.cs
- WaitHandle.cs
- MetadataItemEmitter.cs
- HttpCapabilitiesSectionHandler.cs
- RuntimeHandles.cs
- PlainXmlDeserializer.cs
- Light.cs
- GradientSpreadMethodValidation.cs
- DecoratedNameAttribute.cs
- UidPropertyAttribute.cs
- CapabilitiesSection.cs
- Path.cs
- TextBoxLine.cs
- ShellProvider.cs
- SqlExpressionNullability.cs
- DataGridViewBindingCompleteEventArgs.cs
- WebBrowsableAttribute.cs
- DateTimeOffsetConverter.cs
- RegexRunnerFactory.cs
- SqlEnums.cs
- UnsignedPublishLicense.cs
- SQLString.cs
- ContextMenu.cs
- CompilationRelaxations.cs
- SafeTokenHandle.cs
- PasswordTextContainer.cs
- InputQueue.cs
- LinqDataSourceValidationException.cs
- GroupItemAutomationPeer.cs
- XPathPatternBuilder.cs
- XmlSchemaSequence.cs