Fix for running against RabbitMQ 2.2
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / HttpRuntimeSection.cs
1 //
2 // System.Web.Configuration.HttpRuntimeSection
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32
33 using System;
34 using System.ComponentModel;
35 using System.Configuration;
36
37 namespace System.Web.Configuration
38 {
39         public sealed class HttpRuntimeSection : ConfigurationSection
40         {
41                 static ConfigurationProperty apartmentThreadingProp;
42                 static ConfigurationProperty appRequestQueueLimitProp;
43                 static ConfigurationProperty delayNotificationTimeoutProp;
44                 static ConfigurationProperty enableProp;
45                 static ConfigurationProperty enableHeaderCheckingProp;
46                 static ConfigurationProperty enableKernelOutputCacheProp;
47                 static ConfigurationProperty enableVersionHeaderProp;
48                 static ConfigurationProperty executionTimeoutProp;
49                 static ConfigurationProperty maxRequestLengthProp;
50                 static ConfigurationProperty maxWaitChangeNotificationProp;
51                 static ConfigurationProperty minFreeThreadsProp;
52                 static ConfigurationProperty minLocalRequestFreeThreadsProp;
53                 static ConfigurationProperty requestLengthDiskThresholdProp;
54                 static ConfigurationProperty requireRootedSaveAsPathProp;
55                 static ConfigurationProperty sendCacheControlHeaderProp;
56                 static ConfigurationProperty shutdownTimeoutProp;
57                 static ConfigurationProperty useFullyQualifiedRedirectUrlProp;
58                 static ConfigurationProperty waitChangeNotificationProp;
59 #if NET_4_0
60                 static ConfigurationProperty requestPathInvalidCharactersProp;
61                 static ConfigurationProperty requestValidationTypeProp;
62                 static ConfigurationProperty requestValidationModeProp;
63                 static ConfigurationProperty maxQueryStringLengthProp;
64                 static ConfigurationProperty maxUrlLengthProp;
65                 static ConfigurationProperty encoderTypeProp;
66                 static ConfigurationProperty relaxedUrlToFileSystemMappingProp;
67 #endif
68                 static ConfigurationPropertyCollection properties;
69
70                 static HttpRuntimeSection ()
71                 {
72                         apartmentThreadingProp = new ConfigurationProperty ("apartmentThreading", typeof (bool), false);
73                         appRequestQueueLimitProp = new ConfigurationProperty ("appRequestQueueLimit", typeof (int), 5000,
74                                                                               TypeDescriptor.GetConverter (typeof (int)),
75                                                                               new IntegerValidator (1, Int32.MaxValue),
76                                                                               ConfigurationPropertyOptions.None);
77                         delayNotificationTimeoutProp = new ConfigurationProperty ("delayNotificationTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (5),
78                                                                                   PropertyHelper.TimeSpanSecondsConverter,
79                                                                                   PropertyHelper.DefaultValidator,
80                                                                                   ConfigurationPropertyOptions.None);
81                         enableProp = new ConfigurationProperty ("enable", typeof (bool), true);
82                         enableHeaderCheckingProp = new ConfigurationProperty ("enableHeaderChecking", typeof (bool), true);
83                         enableKernelOutputCacheProp = new ConfigurationProperty ("enableKernelOutputCache", typeof (bool), true);
84                         enableVersionHeaderProp = new ConfigurationProperty ("enableVersionHeader", typeof (bool), true);
85                         executionTimeoutProp = new ConfigurationProperty ("executionTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (110),
86                                                                           PropertyHelper.TimeSpanSecondsConverter,
87                                                                           PropertyHelper.PositiveTimeSpanValidator,
88                                                                           ConfigurationPropertyOptions.None);
89                         maxRequestLengthProp = new ConfigurationProperty ("maxRequestLength", typeof (int), 4096,
90                                                                           TypeDescriptor.GetConverter (typeof (int)),
91                                                                           PropertyHelper.IntFromZeroToMaxValidator,
92                                                                           ConfigurationPropertyOptions.None);
93                         maxWaitChangeNotificationProp = new ConfigurationProperty ("maxWaitChangeNotification", typeof (int), 0,
94                                                                                    TypeDescriptor.GetConverter (typeof (int)),
95                                                                                    PropertyHelper.IntFromZeroToMaxValidator,
96                                                                                    ConfigurationPropertyOptions.None);
97                         minFreeThreadsProp = new ConfigurationProperty ("minFreeThreads", typeof (int), 8,
98                                                                         TypeDescriptor.GetConverter (typeof (int)),
99                                                                         PropertyHelper.IntFromZeroToMaxValidator,
100                                                                         ConfigurationPropertyOptions.None);
101                         minLocalRequestFreeThreadsProp = new ConfigurationProperty ("minLocalRequestFreeThreads", typeof (int), 4,
102                                                                                     TypeDescriptor.GetConverter (typeof (int)),
103                                                                                     PropertyHelper.IntFromZeroToMaxValidator,
104                                                                                     ConfigurationPropertyOptions.None);
105                         requestLengthDiskThresholdProp = new ConfigurationProperty ("requestLengthDiskThreshold", typeof (int), 80,
106                                                                                     TypeDescriptor.GetConverter (typeof (int)),
107                                                                                     new IntegerValidator (1, Int32.MaxValue),
108                                                                                     ConfigurationPropertyOptions.None);
109                         requireRootedSaveAsPathProp = new ConfigurationProperty ("requireRootedSaveAsPath", typeof (bool), true);
110                         sendCacheControlHeaderProp = new ConfigurationProperty ("sendCacheControlHeader", typeof (bool), true);
111                         shutdownTimeoutProp = new ConfigurationProperty ("shutdownTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (90),
112                                                                          PropertyHelper.TimeSpanSecondsConverter,
113                                                                          PropertyHelper.DefaultValidator,
114                                                                          ConfigurationPropertyOptions.None);
115                         useFullyQualifiedRedirectUrlProp = new ConfigurationProperty ("useFullyQualifiedRedirectUrl", typeof (bool), false);
116                         waitChangeNotificationProp = new ConfigurationProperty ("waitChangeNotification", typeof (int), 0,
117                                                                                 TypeDescriptor.GetConverter (typeof (int)),
118                                                                                 PropertyHelper.IntFromZeroToMaxValidator,
119                                                                                 ConfigurationPropertyOptions.None);
120 #if NET_4_0
121                         requestPathInvalidCharactersProp = new ConfigurationProperty ("requestPathInvalidCharacters", typeof (string), ",*,%,&,:,\\,?");
122                         requestValidationTypeProp = new ConfigurationProperty ("requestValidationType", typeof (string),"System.Web.Util.RequestValidator",
123                                                                                TypeDescriptor.GetConverter (typeof (string)),
124                                                                                PropertyHelper.NonEmptyStringValidator,
125                                                                                ConfigurationPropertyOptions.None);
126                         requestValidationModeProp = new ConfigurationProperty ("requestValidationMode", typeof (Version), new Version (4, 0),
127                                                                                PropertyHelper.VersionConverter,
128                                                                                PropertyHelper.DefaultValidator,
129                                                                                ConfigurationPropertyOptions.None);
130                         maxQueryStringLengthProp = new ConfigurationProperty ("maxQueryStringLength", typeof (int), 2048,
131                                                                               TypeDescriptor.GetConverter (typeof (int)),
132                                                                               PropertyHelper.IntFromZeroToMaxValidator,
133                                                                               ConfigurationPropertyOptions.None);
134                         maxUrlLengthProp = new ConfigurationProperty ("maxUrlLength", typeof (int), 260,
135                                                                       TypeDescriptor.GetConverter (typeof (int)),
136                                                                       PropertyHelper.IntFromZeroToMaxValidator,
137                                                                       ConfigurationPropertyOptions.None);
138                         encoderTypeProp = new ConfigurationProperty ("encoderType", typeof (string), "System.Web.Util.HttpEncoder",
139                                                                      TypeDescriptor.GetConverter (typeof (string)),
140                                                                      PropertyHelper.NonEmptyStringValidator,
141                                                                      ConfigurationPropertyOptions.None);
142                         relaxedUrlToFileSystemMappingProp = new ConfigurationProperty ("relaxedUrlToFileSystemMapping", typeof (bool), false);
143 #endif
144                         
145                         properties = new ConfigurationPropertyCollection();
146                         properties.Add (apartmentThreadingProp);
147                         properties.Add (appRequestQueueLimitProp);
148                         properties.Add (delayNotificationTimeoutProp);
149                         properties.Add (enableProp);
150                         properties.Add (enableHeaderCheckingProp);
151                         properties.Add (enableKernelOutputCacheProp);
152                         properties.Add (enableVersionHeaderProp);
153                         properties.Add (executionTimeoutProp);
154                         properties.Add (maxRequestLengthProp);
155                         properties.Add (maxWaitChangeNotificationProp);
156                         properties.Add (minFreeThreadsProp);
157                         properties.Add (minLocalRequestFreeThreadsProp);
158                         properties.Add (requestLengthDiskThresholdProp);
159                         properties.Add (requireRootedSaveAsPathProp);
160                         properties.Add (sendCacheControlHeaderProp);
161                         properties.Add (shutdownTimeoutProp);
162                         properties.Add (useFullyQualifiedRedirectUrlProp);
163                         properties.Add (waitChangeNotificationProp);
164 #if NET_4_0
165                         properties.Add (requestPathInvalidCharactersProp);
166                         properties.Add (requestValidationTypeProp);
167                         properties.Add (requestValidationModeProp);
168                         properties.Add (maxQueryStringLengthProp);
169                         properties.Add (maxUrlLengthProp);
170                         properties.Add (encoderTypeProp);
171                         properties.Add (relaxedUrlToFileSystemMappingProp);
172 #endif
173                 }
174
175                 public HttpRuntimeSection()
176                 {
177                 }
178
179                 [ConfigurationProperty ("apartmentThreading", DefaultValue = "False")]
180                 public bool ApartmentThreading {
181                         get { return (bool) base[apartmentThreadingProp]; }
182                         set { base[apartmentThreadingProp] = value; }
183                 }
184
185                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
186                 [ConfigurationProperty ("appRequestQueueLimit", DefaultValue = "5000")]
187                 public int AppRequestQueueLimit {
188                         get { return (int) base[appRequestQueueLimitProp]; }
189                         set { base[appRequestQueueLimitProp] = value; }
190                 }
191
192                 [TypeConverter (typeof (TimeSpanSecondsConverter))]
193                 [ConfigurationProperty ("delayNotificationTimeout", DefaultValue = "00:00:05")]
194                 public TimeSpan DelayNotificationTimeout {
195                         get { return (TimeSpan) base[delayNotificationTimeoutProp]; }
196                         set { base[delayNotificationTimeoutProp] = value; }
197                 }
198
199                 [ConfigurationProperty ("enable", DefaultValue = "True")]
200                 public bool Enable {
201                         get { return (bool) base[enableProp]; }
202                         set { base[enableProp] = value; }
203                 }
204
205                 [ConfigurationProperty ("enableHeaderChecking", DefaultValue = "True")]
206                 public bool EnableHeaderChecking {
207                         get { return (bool) base[enableHeaderCheckingProp]; }
208                         set { base[enableHeaderCheckingProp] = value; }
209                 }
210
211                 [ConfigurationProperty ("enableKernelOutputCache", DefaultValue = "True")]
212                 public bool EnableKernelOutputCache {
213                         get { return (bool) base[enableKernelOutputCacheProp]; }
214                         set { base[enableKernelOutputCacheProp] = value; }
215                 }
216
217                 [ConfigurationProperty ("enableVersionHeader", DefaultValue = "True")]
218                 public bool EnableVersionHeader {
219                         get { return (bool) base[enableVersionHeaderProp]; }
220                         set { base[enableVersionHeaderProp] = value; }
221                 }
222
223                 [TypeConverter (typeof (TimeSpanSecondsConverter))]
224                 [TimeSpanValidator (MinValueString = "00:00:00")]
225                 [ConfigurationProperty ("executionTimeout", DefaultValue = "00:01:50")]
226                 public TimeSpan ExecutionTimeout {
227                         get { return (TimeSpan) base[executionTimeoutProp]; }
228                         set { base[executionTimeoutProp] = value; }
229                 }
230
231                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
232                 [ConfigurationProperty ("maxRequestLength", DefaultValue = "4096")]
233                 public int MaxRequestLength {
234                         get { return (int) base[maxRequestLengthProp]; }
235                         set { base[maxRequestLengthProp] = value; }
236                 }
237
238                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
239                 [ConfigurationProperty ("maxWaitChangeNotification", DefaultValue = "0")]
240                 public int MaxWaitChangeNotification {
241                         get { return (int) base[maxWaitChangeNotificationProp]; }
242                         set { base[maxWaitChangeNotificationProp] = value; }
243                 }
244
245                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
246                 [ConfigurationProperty ("minFreeThreads", DefaultValue = "8")]
247                 public int MinFreeThreads {
248                         get { return (int) base[minFreeThreadsProp]; }
249                         set { base[minFreeThreadsProp] = value; }
250                 }
251
252                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
253                 [ConfigurationProperty ("minLocalRequestFreeThreads", DefaultValue = "4")]
254                 public int MinLocalRequestFreeThreads {
255                         get { return (int) base[minLocalRequestFreeThreadsProp]; }
256                         set { base[minLocalRequestFreeThreadsProp] = value; }
257                 }
258
259                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
260                 [ConfigurationProperty ("requestLengthDiskThreshold", DefaultValue = "80")]
261                 public int RequestLengthDiskThreshold {
262                         get { return (int) base[requestLengthDiskThresholdProp]; }
263                         set { base[requestLengthDiskThresholdProp] = value; }
264                 }
265
266                 [ConfigurationProperty ("requireRootedSaveAsPath", DefaultValue = "True")]
267                 public bool RequireRootedSaveAsPath {
268                         get { return (bool) base[requireRootedSaveAsPathProp]; }
269                         set { base[requireRootedSaveAsPathProp] = value; }
270                 }
271
272                 [ConfigurationProperty ("sendCacheControlHeader", DefaultValue = "True")]
273                 public bool SendCacheControlHeader {
274                         get { return (bool) base[sendCacheControlHeaderProp]; }
275                         set { base[sendCacheControlHeaderProp] = value; }
276                 }
277
278                 [TypeConverter (typeof (TimeSpanSecondsConverter))]
279                 [ConfigurationProperty ("shutdownTimeout", DefaultValue = "00:01:30")]
280                 public TimeSpan ShutdownTimeout {
281                         get { return (TimeSpan) base[shutdownTimeoutProp]; }
282                         set { base[shutdownTimeoutProp] = value; }
283                 }
284
285                 [ConfigurationProperty ("useFullyQualifiedRedirectUrl", DefaultValue = "False")]
286                 public bool UseFullyQualifiedRedirectUrl {
287                         get { return (bool) base[useFullyQualifiedRedirectUrlProp]; }
288                         set { base[useFullyQualifiedRedirectUrlProp] = value; }
289                 }
290
291                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
292                 [ConfigurationProperty ("waitChangeNotification", DefaultValue = "0")]
293                 public int WaitChangeNotification {
294                         get { return (int) base[waitChangeNotificationProp]; }
295                         set { base[waitChangeNotificationProp] = value; }
296                 }
297
298 #if NET_4_0
299                 [ConfigurationProperty ("requestPathInvalidCharacters", DefaultValue = ",*,%,&,:,\\,?")]
300                 public string RequestPathInvalidCharacters {
301                         get { return (string) base [requestPathInvalidCharactersProp]; }
302                         set { base [requestPathInvalidCharactersProp] = value; }
303                 }
304
305                 [ConfigurationProperty ("requestValidationType", DefaultValue = "System.Web.Util.RequestValidator")]
306                 [StringValidator (MinLength = 1)]
307                 public string RequestValidationType {
308                         get { return (string) base [requestValidationTypeProp]; }
309                         set { base [requestValidationTypeProp] = value; }
310                 }
311
312                 [ConfigurationProperty ("requestValidationMode", DefaultValue = "4.0")]
313                 [TypeConverter ("System.Web.Configuration.VersionConverter")]
314                 public Version RequestValidationMode {
315                         get { return (Version) base [requestValidationModeProp]; }
316                         set { base [requestValidationModeProp] = value; }
317                 }
318
319                 [IntegerValidator (MinValue = 0)]
320                 [ConfigurationProperty ("maxQueryStringLength", DefaultValue = "2048")]
321                 public int MaxQueryStringLength {
322                         get { return (int) base [maxQueryStringLengthProp]; }
323                         set { base [maxQueryStringLengthProp] = value; }
324                 }
325
326                 [IntegerValidator (MinValue = 0)]
327                 [ConfigurationProperty ("maxUrlLength", DefaultValue = "260")]
328                 public int MaxUrlLength {
329                         get { return (int) base [maxUrlLengthProp]; }
330                         set { base [maxUrlLengthProp] = value; }
331                 }
332
333                 [StringValidator (MinLength = 1)]
334                 [ConfigurationProperty ("encoderType", DefaultValue = "System.Web.Util.HttpEncoder")]
335                 public string EncoderType {
336                         get { return (string) base [encoderTypeProp]; }
337                         set { base [encoderTypeProp] = value; }
338                 }
339
340                 [ConfigurationProperty ("relaxedUrlToFileSystemMapping", DefaultValue = "False")]
341                 public bool RelaxedUrlToFileSystemMapping {
342                         get { return (bool) base [relaxedUrlToFileSystemMappingProp]; }
343                         set { base [relaxedUrlToFileSystemMappingProp] = value; }
344                 }
345 #endif
346                 protected override ConfigurationPropertyCollection Properties {
347                         get { return properties; }
348                 }
349         }
350 }
351
352 #endif