2
0

HttpRuntimeSection.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. //
  2. // System.Web.Configuration.HttpRuntimeSection
  3. //
  4. // Authors:
  5. // Chris Toshok ([email protected])
  6. //
  7. // (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.ComponentModel;
  32. using System.Configuration;
  33. namespace System.Web.Configuration
  34. {
  35. public sealed class HttpRuntimeSection : ConfigurationSection
  36. {
  37. static ConfigurationProperty apartmentThreadingProp;
  38. static ConfigurationProperty appRequestQueueLimitProp;
  39. static ConfigurationProperty delayNotificationTimeoutProp;
  40. static ConfigurationProperty enableProp;
  41. static ConfigurationProperty enableHeaderCheckingProp;
  42. static ConfigurationProperty enableKernelOutputCacheProp;
  43. static ConfigurationProperty enableVersionHeaderProp;
  44. static ConfigurationProperty executionTimeoutProp;
  45. static ConfigurationProperty maxRequestLengthProp;
  46. static ConfigurationProperty maxWaitChangeNotificationProp;
  47. static ConfigurationProperty minFreeThreadsProp;
  48. static ConfigurationProperty minLocalRequestFreeThreadsProp;
  49. static ConfigurationProperty requestLengthDiskThresholdProp;
  50. static ConfigurationProperty requireRootedSaveAsPathProp;
  51. static ConfigurationProperty sendCacheControlHeaderProp;
  52. static ConfigurationProperty shutdownTimeoutProp;
  53. static ConfigurationProperty useFullyQualifiedRedirectUrlProp;
  54. static ConfigurationProperty waitChangeNotificationProp;
  55. static ConfigurationPropertyCollection properties;
  56. static HttpRuntimeSection ()
  57. {
  58. apartmentThreadingProp = new ConfigurationProperty ("apartmentThreading", typeof (bool), false);
  59. appRequestQueueLimitProp = new ConfigurationProperty ("appRequestQueueLimit", typeof (int), 5000,
  60. TypeDescriptor.GetConverter (typeof (int)),
  61. new IntegerValidator (1, Int32.MaxValue),
  62. ConfigurationPropertyOptions.None);
  63. delayNotificationTimeoutProp = new ConfigurationProperty ("delayNotificationTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (5),
  64. PropertyHelper.TimeSpanSecondsConverter,
  65. PropertyHelper.DefaultValidator,
  66. ConfigurationPropertyOptions.None);
  67. enableProp = new ConfigurationProperty ("enable", typeof (bool), true);
  68. enableHeaderCheckingProp = new ConfigurationProperty ("enableHeaderChecking", typeof (bool), true);
  69. enableKernelOutputCacheProp = new ConfigurationProperty ("enableKernelOutputCache", typeof (bool), true);
  70. enableVersionHeaderProp = new ConfigurationProperty ("enableVersionHeader", typeof (bool), true);
  71. executionTimeoutProp = new ConfigurationProperty ("executionTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (110),
  72. PropertyHelper.TimeSpanSecondsConverter,
  73. PropertyHelper.PositiveTimeSpanValidator,
  74. ConfigurationPropertyOptions.None);
  75. maxRequestLengthProp = new ConfigurationProperty ("maxRequestLength", typeof (int), 4096,
  76. TypeDescriptor.GetConverter (typeof (int)),
  77. PropertyHelper.IntFromZeroToMaxValidator,
  78. ConfigurationPropertyOptions.None);
  79. maxWaitChangeNotificationProp = new ConfigurationProperty ("maxWaitChangeNotification", typeof (int), 0,
  80. TypeDescriptor.GetConverter (typeof (int)),
  81. PropertyHelper.IntFromZeroToMaxValidator,
  82. ConfigurationPropertyOptions.None);
  83. minFreeThreadsProp = new ConfigurationProperty ("minFreeThreads", typeof (int), 8,
  84. TypeDescriptor.GetConverter (typeof (int)),
  85. PropertyHelper.IntFromZeroToMaxValidator,
  86. ConfigurationPropertyOptions.None);
  87. minLocalRequestFreeThreadsProp = new ConfigurationProperty ("minLocalRequestFreeThreads", typeof (int), 4,
  88. TypeDescriptor.GetConverter (typeof (int)),
  89. PropertyHelper.IntFromZeroToMaxValidator,
  90. ConfigurationPropertyOptions.None);
  91. requestLengthDiskThresholdProp = new ConfigurationProperty ("requestLengthDiskThreshold", typeof (int), 80,
  92. TypeDescriptor.GetConverter (typeof (int)),
  93. new IntegerValidator (1, Int32.MaxValue),
  94. ConfigurationPropertyOptions.None);
  95. requireRootedSaveAsPathProp = new ConfigurationProperty ("requireRootedSaveAsPath", typeof (bool), true);
  96. sendCacheControlHeaderProp = new ConfigurationProperty ("sendCacheControlHeader", typeof (bool), true);
  97. shutdownTimeoutProp = new ConfigurationProperty ("shutdownTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (90),
  98. PropertyHelper.TimeSpanSecondsConverter,
  99. PropertyHelper.DefaultValidator,
  100. ConfigurationPropertyOptions.None);
  101. useFullyQualifiedRedirectUrlProp = new ConfigurationProperty ("useFullyQualifiedRedirectUrl", typeof (bool), false);
  102. waitChangeNotificationProp = new ConfigurationProperty ("waitChangeNotification", typeof (int), 0,
  103. TypeDescriptor.GetConverter (typeof (int)),
  104. PropertyHelper.IntFromZeroToMaxValidator,
  105. ConfigurationPropertyOptions.None);
  106. properties = new ConfigurationPropertyCollection();
  107. properties.Add (apartmentThreadingProp);
  108. properties.Add (appRequestQueueLimitProp);
  109. properties.Add (delayNotificationTimeoutProp);
  110. properties.Add (enableProp);
  111. properties.Add (enableHeaderCheckingProp);
  112. properties.Add (enableKernelOutputCacheProp);
  113. properties.Add (enableVersionHeaderProp);
  114. properties.Add (executionTimeoutProp);
  115. properties.Add (maxRequestLengthProp);
  116. properties.Add (maxWaitChangeNotificationProp);
  117. properties.Add (minFreeThreadsProp);
  118. properties.Add (minLocalRequestFreeThreadsProp);
  119. properties.Add (requestLengthDiskThresholdProp);
  120. properties.Add (requireRootedSaveAsPathProp);
  121. properties.Add (sendCacheControlHeaderProp);
  122. properties.Add (shutdownTimeoutProp);
  123. properties.Add (useFullyQualifiedRedirectUrlProp);
  124. properties.Add (waitChangeNotificationProp);
  125. }
  126. public HttpRuntimeSection()
  127. {
  128. }
  129. [ConfigurationProperty ("apartmentThreading", DefaultValue = "False")]
  130. public bool ApartmentThreading {
  131. get { return (bool) base[apartmentThreadingProp]; }
  132. set { base[apartmentThreadingProp] = value; }
  133. }
  134. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
  135. [ConfigurationProperty ("appRequestQueueLimit", DefaultValue = "5000")]
  136. public int AppRequestQueueLimit {
  137. get { return (int) base[appRequestQueueLimitProp]; }
  138. set { base[appRequestQueueLimitProp] = value; }
  139. }
  140. [TypeConverter (typeof (TimeSpanSecondsConverter))]
  141. [ConfigurationProperty ("delayNotificationTimeout", DefaultValue = "00:00:05")]
  142. public TimeSpan DelayNotificationTimeout {
  143. get { return (TimeSpan) base[delayNotificationTimeoutProp]; }
  144. set { base[delayNotificationTimeoutProp] = value; }
  145. }
  146. [ConfigurationProperty ("enable", DefaultValue = "True")]
  147. public bool Enable {
  148. get { return (bool) base[enableProp]; }
  149. set { base[enableProp] = value; }
  150. }
  151. [ConfigurationProperty ("enableHeaderChecking", DefaultValue = "True")]
  152. public bool EnableHeaderChecking {
  153. get { return (bool) base[enableHeaderCheckingProp]; }
  154. set { base[enableHeaderCheckingProp] = value; }
  155. }
  156. [ConfigurationProperty ("enableKernelOutputCache", DefaultValue = "True")]
  157. public bool EnableKernelOutputCache {
  158. get { return (bool) base[enableKernelOutputCacheProp]; }
  159. set { base[enableKernelOutputCacheProp] = value; }
  160. }
  161. [ConfigurationProperty ("enableVersionHeader", DefaultValue = "True")]
  162. public bool EnableVersionHeader {
  163. get { return (bool) base[enableVersionHeaderProp]; }
  164. set { base[enableVersionHeaderProp] = value; }
  165. }
  166. [TypeConverter (typeof (TimeSpanSecondsConverter))]
  167. [TimeSpanValidator (MinValueString = "00:00:00")]
  168. [ConfigurationProperty ("executionTimeout", DefaultValue = "00:01:50")]
  169. public TimeSpan ExecutionTimeout {
  170. get { return (TimeSpan) base[executionTimeoutProp]; }
  171. set { base[executionTimeoutProp] = value; }
  172. }
  173. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  174. [ConfigurationProperty ("maxRequestLength", DefaultValue = "4096")]
  175. public int MaxRequestLength {
  176. get { return (int) base[maxRequestLengthProp]; }
  177. set { base[maxRequestLengthProp] = value; }
  178. }
  179. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  180. [ConfigurationProperty ("maxWaitChangeNotification", DefaultValue = "0")]
  181. public int MaxWaitChangeNotification {
  182. get { return (int) base[maxWaitChangeNotificationProp]; }
  183. set { base[maxWaitChangeNotificationProp] = value; }
  184. }
  185. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  186. [ConfigurationProperty ("minFreeThreads", DefaultValue = "8")]
  187. public int MinFreeThreads {
  188. get { return (int) base[minFreeThreadsProp]; }
  189. set { base[minFreeThreadsProp] = value; }
  190. }
  191. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  192. [ConfigurationProperty ("minLocalRequestFreeThreads", DefaultValue = "4")]
  193. public int MinLocalRequestFreeThreads {
  194. get { return (int) base[minLocalRequestFreeThreadsProp]; }
  195. set { base[minLocalRequestFreeThreadsProp] = value; }
  196. }
  197. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
  198. [ConfigurationProperty ("requestLengthDiskThreshold", DefaultValue = "80")]
  199. public int RequestLengthDiskThreshold {
  200. get { return (int) base[requestLengthDiskThresholdProp]; }
  201. set { base[requestLengthDiskThresholdProp] = value; }
  202. }
  203. [ConfigurationProperty ("requireRootedSaveAsPath", DefaultValue = "True")]
  204. public bool RequireRootedSaveAsPath {
  205. get { return (bool) base[requireRootedSaveAsPathProp]; }
  206. set { base[requireRootedSaveAsPathProp] = value; }
  207. }
  208. [ConfigurationProperty ("sendCacheControlHeader", DefaultValue = "True")]
  209. public bool SendCacheControlHeader {
  210. get { return (bool) base[sendCacheControlHeaderProp]; }
  211. set { base[sendCacheControlHeaderProp] = value; }
  212. }
  213. [TypeConverter (typeof (TimeSpanSecondsConverter))]
  214. [ConfigurationProperty ("shutdownTimeout", DefaultValue = "00:01:30")]
  215. public TimeSpan ShutdownTimeout {
  216. get { return (TimeSpan) base[shutdownTimeoutProp]; }
  217. set { base[shutdownTimeoutProp] = value; }
  218. }
  219. [ConfigurationProperty ("useFullyQualifiedRedirectUrl", DefaultValue = "False")]
  220. public bool UseFullyQualifiedRedirectUrl {
  221. get { return (bool) base[useFullyQualifiedRedirectUrlProp]; }
  222. set { base[useFullyQualifiedRedirectUrlProp] = value; }
  223. }
  224. [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
  225. [ConfigurationProperty ("waitChangeNotification", DefaultValue = "0")]
  226. public int WaitChangeNotification {
  227. get { return (int) base[waitChangeNotificationProp]; }
  228. set { base[waitChangeNotificationProp] = value; }
  229. }
  230. protected override ConfigurationPropertyCollection Properties {
  231. get { return properties; }
  232. }
  233. }
  234. }
  235. #endif