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
- ColorMatrix.cs
- ClientSettingsProvider.cs
- HwndSourceKeyboardInputSite.cs
- _Rfc2616CacheValidators.cs
- HitTestParameters.cs
- DesignerSerializerAttribute.cs
- ConfigurationElement.cs
- TrustManagerMoreInformation.cs
- CodeIterationStatement.cs
- CacheModeValueSerializer.cs
- ProviderUtil.cs
- ListManagerBindingsCollection.cs
- UntypedNullExpression.cs
- FormCollection.cs
- XmlSchemaAppInfo.cs
- Debug.cs
- Wildcard.cs
- DbDataAdapter.cs
- SmiEventSink.cs
- AssemblyResourceLoader.cs
- ReadOnlyDataSourceView.cs
- HostingEnvironmentException.cs
- Wizard.cs
- CellTreeNodeVisitors.cs
- FixedPageProcessor.cs
- Point3DConverter.cs
- xml.cs
- KnownTypeAttribute.cs
- ManipulationDeltaEventArgs.cs
- WebPartChrome.cs
- DropDownButton.cs
- DBCSCodePageEncoding.cs
- DelegatingConfigHost.cs
- RepeaterDataBoundAdapter.cs
- StyleBamlRecordReader.cs
- BitmapEffectRenderDataResource.cs
- PerformanceCounterLib.cs
- StickyNoteContentControl.cs
- DefaultProxySection.cs
- TrackBar.cs
- CapabilitiesPattern.cs
- WindowsPrincipal.cs
- HtmlTableRow.cs
- ColumnResult.cs
- WFItemsToSpacerVisibility.cs
- DataGridCommandEventArgs.cs
- XmlStringTable.cs
- _FtpControlStream.cs
- DesignerAdapterAttribute.cs
- IriParsingElement.cs
- RepeaterItem.cs
- SmiMetaDataProperty.cs
- HTMLTextWriter.cs
- GradientSpreadMethodValidation.cs
- Native.cs
- ManagementPath.cs
- AvTraceDetails.cs
- OverflowException.cs
- PrincipalPermission.cs
- Substitution.cs
- elementinformation.cs
- WsatServiceCertificate.cs
- OdbcEnvironment.cs
- XsltException.cs
- Hashtable.cs
- Property.cs
- BinaryParser.cs
- MemberDescriptor.cs
- HtmlElement.cs
- DesignerSerializationVisibilityAttribute.cs
- XmlName.cs
- HtmlButton.cs
- GeneralTransform3DTo2D.cs
- ServiceBuildProvider.cs
- TraceUtility.cs
- GeneratedView.cs
- RectangleGeometry.cs
- metadatamappinghashervisitor.cs
- GenericUriParser.cs
- HitTestParameters.cs
- HierarchicalDataBoundControl.cs
- NameValuePair.cs
- JapaneseCalendar.cs
- CompletionCallbackWrapper.cs
- ScriptResourceHandler.cs
- MexHttpBindingElement.cs
- serverconfig.cs
- SrgsGrammarCompiler.cs
- MissingManifestResourceException.cs
- AccessorTable.cs
- StackSpiller.Generated.cs
- Int16Converter.cs
- Configuration.cs
- _ContextAwareResult.cs
- SecurityTraceRecordHelper.cs
- PerformanceCounterPermissionEntryCollection.cs
- Semaphore.cs
- ButtonAutomationPeer.cs
- XmlRawWriterWrapper.cs
- OdbcConnection.cs