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
- ImageIndexConverter.cs
- GenericIdentity.cs
- DropTarget.cs
- WebBrowserBase.cs
- CodeSubDirectory.cs
- WebPartDescription.cs
- GenericXmlSecurityTokenAuthenticator.cs
- XmlDesigner.cs
- ImmutableCommunicationTimeouts.cs
- RecognizeCompletedEventArgs.cs
- XmlQueryRuntime.cs
- ClientTargetCollection.cs
- ObjectAnimationUsingKeyFrames.cs
- DesignerImageAdapter.cs
- SqlXml.cs
- AstTree.cs
- ReflectPropertyDescriptor.cs
- SecurityKeyUsage.cs
- SqlErrorCollection.cs
- SectionInput.cs
- WebRequestModuleElementCollection.cs
- TreeNodeBindingCollection.cs
- HtmlInputControl.cs
- FunctionCommandText.cs
- SqlCacheDependency.cs
- OletxCommittableTransaction.cs
- Simplifier.cs
- TraceHwndHost.cs
- Encoder.cs
- IProvider.cs
- CrossSiteScriptingValidation.cs
- ProfileProvider.cs
- BuilderInfo.cs
- MemberProjectedSlot.cs
- PermissionToken.cs
- DES.cs
- UnmanagedMemoryStream.cs
- Environment.cs
- XMLSyntaxException.cs
- BitmapImage.cs
- Keyboard.cs
- CompilerResults.cs
- ArcSegment.cs
- InterleavedZipPartStream.cs
- AutomationElementIdentifiers.cs
- DataControlFieldCollection.cs
- DigestComparer.cs
- QueryInterceptorAttribute.cs
- UserControlCodeDomTreeGenerator.cs
- DataGridParentRows.cs
- BinaryFormatterSinks.cs
- EditorPartChrome.cs
- ProtocolsSection.cs
- X509CertificateRecipientServiceCredential.cs
- EmptyControlCollection.cs
- CompModHelpers.cs
- DataMisalignedException.cs
- SignatureGenerator.cs
- CodeConstructor.cs
- ToolStripGrip.cs
- MarkupWriter.cs
- EncodedStreamFactory.cs
- ContextMarshalException.cs
- ContextMenu.cs
- Size3D.cs
- XmlImplementation.cs
- MethodBody.cs
- CallbackValidatorAttribute.cs
- InternalResources.cs
- EntitySqlQueryCacheEntry.cs
- PerformanceCountersElement.cs
- PriorityQueue.cs
- XmlWrappingWriter.cs
- XPathExpr.cs
- connectionpool.cs
- GraphicsState.cs
- ReadOnlyCollectionBase.cs
- BaseTemplateParser.cs
- ArcSegment.cs
- ChtmlTextWriter.cs
- Pens.cs
- ListViewDeleteEventArgs.cs
- WebPermission.cs
- MediaEntryAttribute.cs
- AsyncResult.cs
- PropertyStore.cs
- AuthorizationContext.cs
- EditableTreeList.cs
- FileUtil.cs
- ConnectivityStatus.cs
- PersonalizationProviderHelper.cs
- DiscoveryClientRequestChannel.cs
- SqlFileStream.cs
- SrgsItemList.cs
- XmlSortKeyAccumulator.cs
- LateBoundBitmapDecoder.cs
- SqlBuilder.cs
- serverconfig.cs
- VirtualPathProvider.cs
- AspCompat.cs