Code:
/ DotNET / DotNET / 8.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
- TypeToken.cs
- FlowLayout.cs
- EntityConnectionStringBuilderItem.cs
- SqlDataSourceStatusEventArgs.cs
- RelationshipFixer.cs
- RightsManagementEncryptedStream.cs
- InheritanceContextChangedEventManager.cs
- GeneralTransform3DTo2D.cs
- PeerName.cs
- DynamicValueConverter.cs
- DataObjectPastingEventArgs.cs
- StickyNote.cs
- DbModificationClause.cs
- Path.cs
- SQLBinaryStorage.cs
- SortableBindingList.cs
- ReadOnlyCollection.cs
- EncoderParameter.cs
- SslStream.cs
- WinEventQueueItem.cs
- SrgsToken.cs
- EntityContainerEntitySetDefiningQuery.cs
- ComponentManagerBroker.cs
- SqlWriter.cs
- ConnectionProviderAttribute.cs
- PolyQuadraticBezierSegment.cs
- ImageListStreamer.cs
- CodeNamespaceImportCollection.cs
- FormViewModeEventArgs.cs
- Types.cs
- DataGridItem.cs
- RenamedEventArgs.cs
- DataListItem.cs
- TemplateBuilder.cs
- SqlCacheDependencyDatabase.cs
- UserThread.cs
- WsdlWriter.cs
- TextFindEngine.cs
- Literal.cs
- DataSourceSelectArguments.cs
- SharedUtils.cs
- LabelLiteral.cs
- ModelVisual3D.cs
- UnsafePeerToPeerMethods.cs
- COAUTHIDENTITY.cs
- UpdateManifestForBrowserApplication.cs
- util.cs
- IssuanceLicense.cs
- HiddenField.cs
- PageThemeBuildProvider.cs
- RoutedEvent.cs
- HyperlinkAutomationPeer.cs
- FileSystemInfo.cs
- CapabilitiesSection.cs
- MatrixAnimationUsingPath.cs
- TabItemWrapperAutomationPeer.cs
- BamlWriter.cs
- arabicshape.cs
- ZoneLinkButton.cs
- SafeFindHandle.cs
- _FtpControlStream.cs
- QueryPageSettingsEventArgs.cs
- TextParaLineResult.cs
- CompilationAssemblyInstallComponent.cs
- RowVisual.cs
- GradientBrush.cs
- ThicknessAnimationUsingKeyFrames.cs
- Funcletizer.cs
- NamedPipeProcessProtocolHandler.cs
- listitem.cs
- CodeDomExtensionMethods.cs
- FormParameter.cs
- XmlSchemaSequence.cs
- MultiPropertyDescriptorGridEntry.cs
- PopOutPanel.cs
- HWStack.cs
- XPathMultyIterator.cs
- DelegatingConfigHost.cs
- OleDbEnumerator.cs
- CompositeTypefaceMetrics.cs
- RuntimeVariableList.cs
- DefaultSerializationProviderAttribute.cs
- ResourcesBuildProvider.cs
- XmlEncodedRawTextWriter.cs
- DiscreteKeyFrames.cs
- DetailsViewUpdateEventArgs.cs
- Vector3D.cs
- XmlChoiceIdentifierAttribute.cs
- DependencyPropertyKind.cs
- ZipFileInfo.cs
- HttpCookie.cs
- DesignTableCollection.cs
- IUnknownConstantAttribute.cs
- SqlEnums.cs
- WebServiceErrorEvent.cs
- AppSettingsSection.cs
- WeakRefEnumerator.cs
- errorpatternmatcher.cs
- SqlProviderManifest.cs
- columnmapkeybuilder.cs