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
- DataControlFieldCollection.cs
- ISAPIApplicationHost.cs
- MemberHolder.cs
- PropertyInfoSet.cs
- WorkItem.cs
- XmlUnspecifiedAttribute.cs
- ToolBar.cs
- Point3DKeyFrameCollection.cs
- ViewEvent.cs
- WebServiceResponseDesigner.cs
- DesignerWebPartChrome.cs
- RequestTimeoutManager.cs
- ChannelServices.cs
- DocumentViewerConstants.cs
- EventMap.cs
- SrgsRule.cs
- TemplateControlBuildProvider.cs
- RoleGroupCollectionEditor.cs
- precedingquery.cs
- SelectionProcessor.cs
- IIS7WorkerRequest.cs
- PropertyEmitter.cs
- VirtualPathData.cs
- LinkedResource.cs
- GroupQuery.cs
- ItemType.cs
- CompilerResults.cs
- BitStack.cs
- MsmqIntegrationBindingElement.cs
- Rights.cs
- XmlTextWriter.cs
- PresentationSource.cs
- UpdateProgress.cs
- OleDbConnectionFactory.cs
- SqlConnectionPoolProviderInfo.cs
- BufferedGraphics.cs
- InheritanceContextChangedEventManager.cs
- DebugView.cs
- Storyboard.cs
- SortDescriptionCollection.cs
- HostProtectionPermission.cs
- TextBoxBase.cs
- HttpContext.cs
- ForEachDesigner.xaml.cs
- ListItemParagraph.cs
- XmlElementAttribute.cs
- Html32TextWriter.cs
- XMLSchema.cs
- DataServiceQueryProvider.cs
- LazyTextWriterCreator.cs
- CaseStatement.cs
- Brush.cs
- ActiveXSite.cs
- ObjectSecurity.cs
- DataTableMappingCollection.cs
- EnterpriseServicesHelper.cs
- SubMenuStyleCollection.cs
- ListInitExpression.cs
- SQLDecimalStorage.cs
- WmfPlaceableFileHeader.cs
- SmiEventSink_Default.cs
- EntityDataSourceStatementEditor.cs
- ProfileSection.cs
- figurelength.cs
- QilUnary.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- InternalTypeHelper.cs
- ToolStripGripRenderEventArgs.cs
- ErasingStroke.cs
- ColorTranslator.cs
- FileReader.cs
- CodeChecksumPragma.cs
- Figure.cs
- Page.cs
- LinkUtilities.cs
- XmlILOptimizerVisitor.cs
- ClickablePoint.cs
- HebrewCalendar.cs
- SourceSwitch.cs
- XmlAttributeProperties.cs
- CodeIdentifier.cs
- XmlLinkedNode.cs
- ParserOptions.cs
- DataRowComparer.cs
- SizeConverter.cs
- TagPrefixInfo.cs
- WebPartMinimizeVerb.cs
- ConfigurationManagerHelperFactory.cs
- IFlowDocumentViewer.cs
- StringValueSerializer.cs
- Comparer.cs
- PageEventArgs.cs
- CustomLineCap.cs
- ForwardPositionQuery.cs
- FileInfo.cs
- GeometryCombineModeValidation.cs
- RegionData.cs
- Nodes.cs
- FileDialog.cs
- StorageEntitySetMapping.cs