Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / HttpResponseHeader.cs / 3 / HttpResponseHeader.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * Single http header representation * * Copyright (c) 1998 Microsoft Corporation */ namespace System.Web { using System.Collections; /* * Response header (either known or unknown) */ internal class HttpResponseHeader { private String _unknownHeader; private int _knownHeaderIndex; private String _value; private static readonly char [] s_BadChars = new char[] {'\n', '\r', '\0'}; internal HttpResponseHeader(int knownHeaderIndex, String value) { _unknownHeader = null; _knownHeaderIndex = knownHeaderIndex; // encode header value if if(HttpRuntime.EnableHeaderChecking) { _value = MaybeEncodeHeader(value); } else { _value = value; } } internal HttpResponseHeader(String unknownHeader, String value) { if(HttpRuntime.EnableHeaderChecking) { _unknownHeader = MaybeEncodeHeader(unknownHeader); _knownHeaderIndex = HttpWorkerRequest.GetKnownResponseHeaderIndex(_unknownHeader); _value = MaybeEncodeHeader(value); } else { _unknownHeader = unknownHeader; _knownHeaderIndex = HttpWorkerRequest.GetKnownResponseHeaderIndex(_unknownHeader); _value = value; } } internal virtual String Name { get { if (_unknownHeader != null) return _unknownHeader; else return HttpWorkerRequest.GetKnownResponseHeaderName(_knownHeaderIndex); } } internal String Value { get { return _value;} } internal void Send(HttpWorkerRequest wr) { if (_knownHeaderIndex >= 0) wr.SendKnownResponseHeader(_knownHeaderIndex, _value); else wr.SendUnknownResponseHeader(_unknownHeader, _value); } // Encode the header if it contains a CRLF pair // VSWhidbey 257154 internal static string MaybeEncodeHeader(string value) { string sanitizedHeader = value; if (value.IndexOfAny(s_BadChars) >= 0) { // if we found a CRLF pair or NULL in the header, replace it // this is slow but isn't expected to occur often // review: will any clients try to decode this? // should it just be a space? sanitizedHeader = value.Replace("\n", "%0a"); sanitizedHeader = sanitizedHeader.Replace("\r", "%0d"); sanitizedHeader = sanitizedHeader.Replace("\0", "%00"); } return sanitizedHeader; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EditorZoneBase.cs
- MultilineStringConverter.cs
- BindUriHelper.cs
- Calendar.cs
- MobileUserControlDesigner.cs
- ConnectionPoint.cs
- DiscoveryDocumentLinksPattern.cs
- PersonalizationStateQuery.cs
- DockingAttribute.cs
- ProfessionalColors.cs
- DeferredRunTextReference.cs
- DBSchemaRow.cs
- QueryComponents.cs
- ServiceHttpHandlerFactory.cs
- MenuAutomationPeer.cs
- DbConnectionHelper.cs
- DispatcherProcessingDisabled.cs
- AuthorizationRuleCollection.cs
- SHA1Managed.cs
- EastAsianLunisolarCalendar.cs
- LocalizedNameDescriptionPair.cs
- InputReferenceExpression.cs
- WsiProfilesElement.cs
- SR.cs
- DecoderNLS.cs
- MessageContractAttribute.cs
- AssemblyBuilder.cs
- WebResourceUtil.cs
- documentsequencetextcontainer.cs
- PathFigureCollectionConverter.cs
- XmlToDatasetMap.cs
- ListControlDesigner.cs
- XmlSchemaObject.cs
- securestring.cs
- ElementAtQueryOperator.cs
- ButtonFieldBase.cs
- ObjectDataSourceFilteringEventArgs.cs
- WebPartDisplayModeCancelEventArgs.cs
- util.cs
- ToolStripRenderer.cs
- MetadataUtil.cs
- DelegatedStream.cs
- IndicFontClient.cs
- CacheDict.cs
- HttpBrowserCapabilitiesWrapper.cs
- WindowsButton.cs
- UIElement3D.cs
- Panel.cs
- ClientTargetCollection.cs
- FontNamesConverter.cs
- SslStream.cs
- UrlParameterReader.cs
- TimeEnumHelper.cs
- SequentialUshortCollection.cs
- ForAllOperator.cs
- SQLInt16Storage.cs
- sqlpipe.cs
- BinHexDecoder.cs
- NamespaceQuery.cs
- BigIntegerStorage.cs
- SafePipeHandle.cs
- StylusOverProperty.cs
- AutomationPatternInfo.cs
- ResXBuildProvider.cs
- UnhandledExceptionEventArgs.cs
- SqlException.cs
- SqlCacheDependencyDatabase.cs
- SQLGuid.cs
- TemplateControlBuildProvider.cs
- DataGridViewSortCompareEventArgs.cs
- BorderSidesEditor.cs
- MeasurementDCInfo.cs
- HtmlMeta.cs
- FacetEnabledSchemaElement.cs
- ValidationSummaryDesigner.cs
- listitem.cs
- DictionarySurrogate.cs
- BackoffTimeoutHelper.cs
- PatternMatchRules.cs
- MapPathBasedVirtualPathProvider.cs
- RectangleGeometry.cs
- HttpContext.cs
- NameSpaceExtractor.cs
- XmlHierarchicalDataSourceView.cs
- Mapping.cs
- CombinedGeometry.cs
- ManagementPath.cs
- CodeArrayIndexerExpression.cs
- TraceSection.cs
- ListViewGroupItemCollection.cs
- WebPartTransformerCollection.cs
- ToolStripLabel.cs
- ReflectionPermission.cs
- _NativeSSPI.cs
- DesignerView.cs
- DataGridAutomationPeer.cs
- SelectionWordBreaker.cs
- InternalConfirm.cs
- XPathNodeList.cs
- ScrollPatternIdentifiers.cs