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
- AccessorTable.cs
- DesignerDataConnection.cs
- WindowsSolidBrush.cs
- _ShellExpression.cs
- PackagePart.cs
- TypeEnumerableViewSchema.cs
- Util.cs
- SafeReadContext.cs
- SettingsProviderCollection.cs
- Function.cs
- CategoryEditor.cs
- LabelEditEvent.cs
- HMACSHA256.cs
- CreateUserErrorEventArgs.cs
- ConfigUtil.cs
- Transform.cs
- SHA384.cs
- ProviderConnectionPoint.cs
- DataGridViewHitTestInfo.cs
- ListControl.cs
- XPathException.cs
- FlowDecisionDesigner.xaml.cs
- WithParamAction.cs
- BindingExpression.cs
- PropertyTabChangedEvent.cs
- CommandField.cs
- SoapReflectionImporter.cs
- ClientScriptManager.cs
- InternalControlCollection.cs
- RangeContentEnumerator.cs
- CreateUserErrorEventArgs.cs
- RotateTransform3D.cs
- NominalTypeEliminator.cs
- ApplicationFileCodeDomTreeGenerator.cs
- TableCellCollection.cs
- Baml6Assembly.cs
- DataKeyCollection.cs
- InternalRelationshipCollection.cs
- InstanceCollisionException.cs
- invalidudtexception.cs
- SafeCloseHandleCritical.cs
- ConfigurationManagerInternalFactory.cs
- ProgressChangedEventArgs.cs
- FontUnitConverter.cs
- TypefaceMap.cs
- ValidationResult.cs
- EFDataModelProvider.cs
- MenuItem.cs
- PolyLineSegmentFigureLogic.cs
- FloatUtil.cs
- Int64Storage.cs
- DashStyle.cs
- SqlGenerator.cs
- PageTheme.cs
- DictionaryManager.cs
- Inflater.cs
- IODescriptionAttribute.cs
- StoreItemCollection.Loader.cs
- HTMLTagNameToTypeMapper.cs
- XamlDesignerSerializationManager.cs
- ProjectionQueryOptionExpression.cs
- Claim.cs
- MissingMemberException.cs
- WebPartTransformer.cs
- CompilerGlobalScopeAttribute.cs
- GridViewColumnHeader.cs
- LiteralTextParser.cs
- TimelineGroup.cs
- ValidatorCompatibilityHelper.cs
- XmlText.cs
- TaskExtensions.cs
- MenuCommands.cs
- Logging.cs
- SiteMapNodeItemEventArgs.cs
- CreateParams.cs
- PipeConnection.cs
- UserControlBuildProvider.cs
- CollectionViewGroupInternal.cs
- Vector3D.cs
- LogicalMethodInfo.cs
- QueryOutputWriterV1.cs
- CompoundFileStorageReference.cs
- BufferedWebEventProvider.cs
- SessionPageStatePersister.cs
- ReadWriteObjectLock.cs
- DetailsViewInsertEventArgs.cs
- BinaryMethodMessage.cs
- Blend.cs
- QilVisitor.cs
- X509ServiceCertificateAuthentication.cs
- CodeCompileUnit.cs
- CacheModeConverter.cs
- OledbConnectionStringbuilder.cs
- MessageOperationFormatter.cs
- RemoteWebConfigurationHostServer.cs
- ContractNamespaceAttribute.cs
- NameValuePermission.cs
- ShapeTypeface.cs
- CacheRequest.cs
- QueryOperationResponseOfT.cs