[System.Net] Add support for .pac proxy config scripts on mac
[mono.git] / mcs / class / System.Web / System.Web / HttpContext.jvm.cs
1 //
2 // System.Web.HttpContext.cs 
3 //
4 // Author:
5 //      Eyal Alaluf (eyala@mainsoft.com)
6 //
7
8 //
9 // Copyright (C) 2005 Mainsoft Co. (http://www.mainsoft.com)
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 using System.Collections;
32 using System.Configuration;
33 using System.Threading;
34 using javax.servlet.http;
35 using javax.faces.context;
36 using System.Web.J2EE;
37 using System.Web.UI;
38 using javax.servlet;
39 using System.Collections.Specialized;
40 using Mainsoft.Web;
41
42 namespace System.Web {
43         
44         public sealed partial class HttpContext {
45                 static readonly LocalDataStoreSlot _ContextSlot = Thread.GetNamedDataSlot ("Context");
46                 // No remoting support (CallContext) yet in Grasshopper
47                 [MonoInternalNote("Context - Use System.Remoting.Messaging.CallContext instead of Thread storage")]
48                 public static HttpContext Current
49                 {
50                         get { return (HttpContext) Thread.GetData (_ContextSlot); }
51                         set { Thread.SetData (_ContextSlot, value); }
52                 }
53
54                 public bool IsDebuggingEnabled { get { return false; } }
55
56                 internal bool IsServletRequest {
57                         get { return ServletRequest != null; }
58                 }
59
60                 internal object GetWorkerService(Type t)
61                 {
62                         IServiceProvider prv = WorkerRequest as IServiceProvider;
63                         return prv != null ? prv.GetService(t) : null;
64                 }
65
66                 internal HttpServlet Servlet {
67                         get { return (HttpServlet)GetWorkerService(typeof(HttpServlet)); }
68                 }
69
70                 internal HttpServletRequest ServletRequest {
71                         get { return (HttpServletRequest)GetWorkerService(typeof(HttpServletRequest)); }
72                 }
73                 
74                 internal NameValueCollection RequestParameters {
75                         get { return (NameValueCollection) GetWorkerService (typeof (NameValueCollection)); }
76                 }
77
78                 internal HttpServletResponse ServletResponse {
79                         get { return (HttpServletResponse)GetWorkerService(typeof(HttpServletResponse)); }
80                 }
81
82                 HttpRuntime _httpRuntime = null;
83                 internal HttpRuntime HttpRuntimeInstance {
84                         get
85                         {
86                                 if (_httpRuntime == null)
87                                         _httpRuntime = (HttpRuntime) AppDomain.CurrentDomain.GetData ("HttpRuntime");
88                                 return _httpRuntime;
89                         }
90                 }
91
92                 static Hashtable resourceManagerCache
93                 {
94                         get
95                         {
96                                 Hashtable cache = (Hashtable) AppDomain.CurrentDomain.GetData ("ResourceManagerCache");
97                                 if (cache == null) {
98                                         cache = new Hashtable ();
99                                         AppDomain.CurrentDomain.SetData ("ResourceManagerCache", cache);
100                                 }
101                                 return cache;
102                         }
103                         set
104                         {
105                                 AppDomain.CurrentDomain.SetData ("ResourceManagerCache", value);
106                         }
107                 }
108
109                 // Timeout is not supported in GH
110                 internal bool CheckIfTimeout (DateTime t)
111                 {
112                         return false;
113                 }
114
115                 internal bool TimeoutPossible
116                 {
117                         get { return true; }
118                 }
119
120                 internal void BeginTimeoutPossible ()
121                 {
122                 }
123
124                 internal void EndTimeoutPossible ()
125                 {
126                 }
127
128                 internal void SetWorkerRequest (HttpWorkerRequest wr) {
129                         WorkerRequest = wr;
130                         Request.SetWorkerRequest (wr);
131                         Response.SetWorkerRequest (wr);
132                 }
133
134                 Page _currentHandlerInternal;
135                 internal Page CurrentHandlerInternal
136                 {
137                         get { return _currentHandlerInternal; }
138                         set { _currentHandlerInternal = value; }
139                 }
140         }
141 }