Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Configuration / HttpWebRequestElement.cs / 1305376 / 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
- ReflectionServiceProvider.cs
- ArgumentNullException.cs
- MouseDevice.cs
- ArrayElementGridEntry.cs
- ExtendedPropertyCollection.cs
- ClientSideProviderDescription.cs
- SiteMapProvider.cs
- DataFormats.cs
- XmlDocument.cs
- TextEditorContextMenu.cs
- ConnectionPoolManager.cs
- ClientScriptManager.cs
- MenuScrollingVisibilityConverter.cs
- TypedTableBaseExtensions.cs
- SapiRecoContext.cs
- EmbeddedObject.cs
- HttpBrowserCapabilitiesBase.cs
- CacheChildrenQuery.cs
- VisualTreeUtils.cs
- PagerSettings.cs
- ScalarConstant.cs
- TextTreeRootNode.cs
- PrtCap_Public_Simple.cs
- Line.cs
- Help.cs
- BitmapEffectGeneralTransform.cs
- AspNetSynchronizationContext.cs
- DataGridTablesFactory.cs
- LicFileLicenseProvider.cs
- MultiSelectRootGridEntry.cs
- Link.cs
- QuaternionAnimationUsingKeyFrames.cs
- GenerateHelper.cs
- WindowsFormsHostAutomationPeer.cs
- processwaithandle.cs
- ViewGenResults.cs
- MailSettingsSection.cs
- Matrix.cs
- ObservableDictionary.cs
- FileDialog_Vista.cs
- DynamicContractTypeBuilder.cs
- RangeValuePattern.cs
- SubMenuStyleCollection.cs
- AsymmetricKeyExchangeDeformatter.cs
- SqlExpressionNullability.cs
- ServiceAuthorizationBehavior.cs
- TextMessageEncoder.cs
- CodeIterationStatement.cs
- DataGridViewColumnHeaderCell.cs
- DataTablePropertyDescriptor.cs
- AssemblyBuilder.cs
- DoubleLinkListEnumerator.cs
- ProcessingInstructionAction.cs
- StylusCollection.cs
- Page.cs
- _BasicClient.cs
- ProtectedProviderSettings.cs
- WeakEventTable.cs
- DetailsViewUpdatedEventArgs.cs
- TagPrefixInfo.cs
- PropertyIdentifier.cs
- SelectedGridItemChangedEvent.cs
- ScriptServiceAttribute.cs
- ReachFixedPageSerializerAsync.cs
- DataColumnPropertyDescriptor.cs
- BuildProviderAppliesToAttribute.cs
- ListViewItemSelectionChangedEvent.cs
- Invariant.cs
- CorrelationKey.cs
- CharacterString.cs
- DBSchemaRow.cs
- XmlAttributeAttribute.cs
- CryptoConfig.cs
- Base64Encoder.cs
- AssemblyInfo.cs
- FeatureSupport.cs
- XmlNotation.cs
- PropertyTabAttribute.cs
- FloatMinMaxAggregationOperator.cs
- EntityDataSourceStatementEditorForm.cs
- ClientCultureInfo.cs
- ConnectionPointCookie.cs
- GroupBoxRenderer.cs
- TextTreeDeleteContentUndoUnit.cs
- XPathPatternBuilder.cs
- DefaultShape.cs
- OleDbReferenceCollection.cs
- IntegerValidator.cs
- Sql8ExpressionRewriter.cs
- CryptoApi.cs
- TransactionProxy.cs
- MasterPage.cs
- FontCacheUtil.cs
- AbandonedMutexException.cs
- CqlErrorHelper.cs
- AttributeProviderAttribute.cs
- CellTreeNode.cs
- FixedPosition.cs
- PersonalizableAttribute.cs
- TeredoHelper.cs