Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Net / System / Net / Configuration / HttpWebRequestElement.cs / 1 / HttpWebRequestElement.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Configuration { using System; using System.Configuration; using System.Reflection; using System.Security.Permissions; public sealed class HttpWebRequestElement : ConfigurationElement { public HttpWebRequestElement() { this.properties.Add(this.maximumResponseHeadersLength); this.properties.Add(this.maximumErrorResponseLength); this.properties.Add(this.maximumUnauthorizedUploadLength); this.properties.Add(this.useUnsafeHeaderParsing); } protected override void PostDeserialize() { // Perf optimization. If the configuration is coming from machine.config // It is safe and we don't need to check for permissions. if (EvaluationContext.IsMachineLevel) return; PropertyInformation[] protectedProperties = { ElementInformation.Properties[ConfigurationStrings.MaximumResponseHeadersLength], ElementInformation.Properties[ConfigurationStrings.MaximumErrorResponseLength] }; foreach (PropertyInformation property in protectedProperties) if (property.ValueOrigin == PropertyValueOrigin.SetHere) { try { ExceptionHelper.WebPermissionUnrestricted.Demand(); } catch (Exception exception) { throw new ConfigurationErrorsException( SR.GetString(SR.net_config_property_permission, property.Name), exception); } } } protected override ConfigurationPropertyCollection Properties { get { return this.properties; } } [ConfigurationProperty(ConfigurationStrings.maximumUnauthorizedUploadLength, DefaultValue=(int)(-1))] public int MaximumUnauthorizedUploadLength { get { return (int)this[this.maximumUnauthorizedUploadLength]; } set { this[this.maximumUnauthorizedUploadLength] = value; } } [ConfigurationProperty(ConfigurationStrings.MaximumErrorResponseLength, DefaultValue=(int)(64))] public int MaximumErrorResponseLength { get { return (int)this[this.maximumErrorResponseLength]; } set { this[this.maximumErrorResponseLength] = value; } } [ConfigurationProperty(ConfigurationStrings.MaximumResponseHeadersLength, DefaultValue= 64)] public int MaximumResponseHeadersLength { get { return (int)this[this.maximumResponseHeadersLength]; } set { this[this.maximumResponseHeadersLength] = value; } } [ConfigurationProperty(ConfigurationStrings.UseUnsafeHeaderParsing, DefaultValue= false)] public bool UseUnsafeHeaderParsing { get { return (bool) this[this.useUnsafeHeaderParsing]; } set { this[this.useUnsafeHeaderParsing] = value; } } ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); readonly ConfigurationProperty maximumResponseHeadersLength = new ConfigurationProperty(ConfigurationStrings.MaximumResponseHeadersLength, typeof(int), 64, ConfigurationPropertyOptions.None); readonly ConfigurationProperty maximumErrorResponseLength = new ConfigurationProperty(ConfigurationStrings.MaximumErrorResponseLength, typeof(int), 64, ConfigurationPropertyOptions.None); readonly ConfigurationProperty maximumUnauthorizedUploadLength = new ConfigurationProperty(ConfigurationStrings.maximumUnauthorizedUploadLength, typeof(int), -1, ConfigurationPropertyOptions.None); readonly ConfigurationProperty useUnsafeHeaderParsing = new ConfigurationProperty(ConfigurationStrings.UseUnsafeHeaderParsing, typeof(bool), false, ConfigurationPropertyOptions.None); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Configuration { using System; using System.Configuration; using System.Reflection; using System.Security.Permissions; public sealed class HttpWebRequestElement : ConfigurationElement { public HttpWebRequestElement() { this.properties.Add(this.maximumResponseHeadersLength); this.properties.Add(this.maximumErrorResponseLength); this.properties.Add(this.maximumUnauthorizedUploadLength); this.properties.Add(this.useUnsafeHeaderParsing); } protected override void PostDeserialize() { // Perf optimization. If the configuration is coming from machine.config // It is safe and we don't need to check for permissions. if (EvaluationContext.IsMachineLevel) return; PropertyInformation[] protectedProperties = { ElementInformation.Properties[ConfigurationStrings.MaximumResponseHeadersLength], ElementInformation.Properties[ConfigurationStrings.MaximumErrorResponseLength] }; foreach (PropertyInformation property in protectedProperties) if (property.ValueOrigin == PropertyValueOrigin.SetHere) { try { ExceptionHelper.WebPermissionUnrestricted.Demand(); } catch (Exception exception) { throw new ConfigurationErrorsException( SR.GetString(SR.net_config_property_permission, property.Name), exception); } } } protected override ConfigurationPropertyCollection Properties { get { return this.properties; } } [ConfigurationProperty(ConfigurationStrings.maximumUnauthorizedUploadLength, DefaultValue=(int)(-1))] public int MaximumUnauthorizedUploadLength { get { return (int)this[this.maximumUnauthorizedUploadLength]; } set { this[this.maximumUnauthorizedUploadLength] = value; } } [ConfigurationProperty(ConfigurationStrings.MaximumErrorResponseLength, DefaultValue=(int)(64))] public int MaximumErrorResponseLength { get { return (int)this[this.maximumErrorResponseLength]; } set { this[this.maximumErrorResponseLength] = value; } } [ConfigurationProperty(ConfigurationStrings.MaximumResponseHeadersLength, DefaultValue= 64)] public int MaximumResponseHeadersLength { get { return (int)this[this.maximumResponseHeadersLength]; } set { this[this.maximumResponseHeadersLength] = value; } } [ConfigurationProperty(ConfigurationStrings.UseUnsafeHeaderParsing, DefaultValue= false)] public bool UseUnsafeHeaderParsing { get { return (bool) this[this.useUnsafeHeaderParsing]; } set { this[this.useUnsafeHeaderParsing] = value; } } ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); readonly ConfigurationProperty maximumResponseHeadersLength = new ConfigurationProperty(ConfigurationStrings.MaximumResponseHeadersLength, typeof(int), 64, ConfigurationPropertyOptions.None); readonly ConfigurationProperty maximumErrorResponseLength = new ConfigurationProperty(ConfigurationStrings.MaximumErrorResponseLength, typeof(int), 64, ConfigurationPropertyOptions.None); readonly ConfigurationProperty maximumUnauthorizedUploadLength = new ConfigurationProperty(ConfigurationStrings.maximumUnauthorizedUploadLength, typeof(int), -1, ConfigurationPropertyOptions.None); readonly ConfigurationProperty useUnsafeHeaderParsing = new ConfigurationProperty(ConfigurationStrings.UseUnsafeHeaderParsing, typeof(bool), false, ConfigurationPropertyOptions.None); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FormsAuthenticationConfiguration.cs
- RotationValidation.cs
- FormatterServices.cs
- GeometryConverter.cs
- VisualBasicExpressionConverter.cs
- ConnectionPoolManager.cs
- CodeMemberMethod.cs
- InfoCardRSACryptoProvider.cs
- _NegotiateClient.cs
- SystemIPv4InterfaceProperties.cs
- ColumnResizeAdorner.cs
- RefExpr.cs
- Assert.cs
- HebrewCalendar.cs
- SapiAttributeParser.cs
- ComponentDispatcher.cs
- GridViewColumnHeader.cs
- String.cs
- CollectionChange.cs
- DockProviderWrapper.cs
- TrackBarRenderer.cs
- SerialReceived.cs
- PointCollection.cs
- SelectionWordBreaker.cs
- ZipIOExtraField.cs
- BuilderPropertyEntry.cs
- TreeNode.cs
- AttachedPropertyMethodSelector.cs
- MappingModelBuildProvider.cs
- PixelFormatConverter.cs
- Matrix.cs
- NativeMethods.cs
- PropertyChange.cs
- DesignerLoader.cs
- ClosableStream.cs
- AnnouncementDispatcherAsyncResult.cs
- ResourcePool.cs
- DropShadowEffect.cs
- KnownBoxes.cs
- PropertyInformation.cs
- WorkflowInstanceTerminatedRecord.cs
- MaskedTextBoxDesigner.cs
- Vertex.cs
- HMACSHA1.cs
- CompensationHandlingFilter.cs
- ChildTable.cs
- HttpStreams.cs
- DateTimeConverter2.cs
- FixedSOMPage.cs
- CodeVariableDeclarationStatement.cs
- AutomationEventArgs.cs
- EncodingNLS.cs
- SetState.cs
- EntityDataSourceChangedEventArgs.cs
- HttpUnhandledOperationInvoker.cs
- EncryptedPackage.cs
- SymDocumentType.cs
- CorrelationKeyCalculator.cs
- SessionStateUtil.cs
- WebPartTransformer.cs
- DataGridView.cs
- ReferentialConstraint.cs
- KeyboardNavigation.cs
- GenericQueueSurrogate.cs
- DesignTimeValidationFeature.cs
- XmlRootAttribute.cs
- PartitionerStatic.cs
- KeyFrames.cs
- InstanceKeyCollisionException.cs
- AnnotationMap.cs
- PrintDocument.cs
- PnrpPeerResolver.cs
- IconConverter.cs
- SqlBuffer.cs
- SQLInt16Storage.cs
- BinaryObjectReader.cs
- ProtectedProviderSettings.cs
- SafeFreeMibTable.cs
- XPathScanner.cs
- ListViewCancelEventArgs.cs
- DataColumnCollection.cs
- DocumentSequence.cs
- ScriptComponentDescriptor.cs
- Update.cs
- FontStretchConverter.cs
- ProfileInfo.cs
- MetadataExchangeClient.cs
- ArgumentException.cs
- AsyncOperationManager.cs
- Utils.cs
- ContextMenu.cs
- HttpContext.cs
- MatrixValueSerializer.cs
- TextTreeExtractElementUndoUnit.cs
- Filter.cs
- TempFiles.cs
- URI.cs
- Variable.cs
- AsymmetricSecurityProtocolFactory.cs
- HGlobalSafeHandle.cs