2004-03-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.Configuration / HttpRuntimeConfig.cs
1 //
2 // System.Web.Configuration.HttpRuntimeConfig
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2003 Novell, Inc. (http://www.novell.com)
8 //
9
10 using System;
11 using System.CodeDom.Compiler;
12 using System.Collections;
13 using System.Configuration;
14 using System.IO;
15 using System.Web;
16 using System.Xml;
17
18 namespace System.Web.Configuration
19 {
20         sealed class HttpRuntimeConfig
21         {
22                 public int ExecutionTimeout = 90; // seconds
23                 public int MaxRequestLength = 4096; // KB
24                 public int RequestLengthDiskThreshold = 256; // KB
25                 public bool UseFullyQualifiedRedirectUrl = false;
26                 public int MinFreeThreads = 8;
27                 public int MinLocalRequestFreeThreads = 4;
28                 public int AppRequestQueueLimit = 100;
29                 public bool EnableKernelOutputCache = true;
30                 public bool EnableVersionHeader = true;
31                 public bool RequireRootSaveAsPath = true;
32                 public int IdleTimeout = 20; // minutes
33                 public bool Enable = true;
34                 public string VersionHeader;
35
36                 /* Only the config. handler should create instances of this. Use GetInstance (context) */
37                 public HttpRuntimeConfig (object p)
38                 {
39                         HttpRuntimeConfig parent = p as HttpRuntimeConfig;
40                         if (parent != null)
41                                 Init (parent);
42                 }
43
44                 static public HttpRuntimeConfig GetInstance (HttpContext context)
45                 {
46                         HttpRuntimeConfig config;
47                         if (context == null)
48                                 context = HttpContext.Context;
49
50                         config = context.GetConfig ("system.web/httpRuntime") as HttpRuntimeConfig;
51
52                         if (config == null)
53                                 throw new Exception ("Configuration error.");
54
55                         return config;
56                 }
57                 
58                 void Init (HttpRuntimeConfig parent)
59                 {
60                         ExecutionTimeout = parent.ExecutionTimeout;
61                         MaxRequestLength = parent.MaxRequestLength;
62                         RequestLengthDiskThreshold = parent.RequestLengthDiskThreshold;
63                         UseFullyQualifiedRedirectUrl = parent.UseFullyQualifiedRedirectUrl;
64                         MinFreeThreads = parent.MinFreeThreads;
65                         MinLocalRequestFreeThreads = parent.MinLocalRequestFreeThreads;
66                         AppRequestQueueLimit = parent.AppRequestQueueLimit;
67                         EnableKernelOutputCache = parent.EnableKernelOutputCache;
68                         EnableVersionHeader = parent.EnableVersionHeader;
69                         RequireRootSaveAsPath = parent.RequireRootSaveAsPath;
70                         IdleTimeout = parent.IdleTimeout;
71                         Enable = parent.Enable;
72                 }
73         }
74 }
75