2 // System.Web.HttpContext.cs
5 // Eyal Alaluf (eyala@mainsoft.com)
9 // Copyright (C) 2005 Mainsoft Co. (http://www.mainsoft.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
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;
39 using System.Collections.Specialized;
42 namespace System.Web {
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
50 get { return (HttpContext) Thread.GetData (_ContextSlot); }
51 set { Thread.SetData (_ContextSlot, value); }
54 public bool IsDebuggingEnabled { get { return false; } }
56 internal bool IsServletRequest {
57 get { return ServletRequest != null; }
60 internal object GetWorkerService(Type t)
62 IServiceProvider prv = WorkerRequest as IServiceProvider;
63 return prv != null ? prv.GetService(t) : null;
66 internal HttpServlet Servlet {
67 get { return (HttpServlet)GetWorkerService(typeof(HttpServlet)); }
70 internal HttpServletRequest ServletRequest {
71 get { return (HttpServletRequest)GetWorkerService(typeof(HttpServletRequest)); }
74 internal NameValueCollection RequestParameters {
75 get { return (NameValueCollection) GetWorkerService (typeof (NameValueCollection)); }
78 internal HttpServletResponse ServletResponse {
79 get { return (HttpServletResponse)GetWorkerService(typeof(HttpServletResponse)); }
82 HttpRuntime _httpRuntime = null;
83 internal HttpRuntime HttpRuntimeInstance {
86 if (_httpRuntime == null)
87 _httpRuntime = (HttpRuntime) AppDomain.CurrentDomain.GetData ("HttpRuntime");
92 static Hashtable resourceManagerCache
96 Hashtable cache = (Hashtable) AppDomain.CurrentDomain.GetData ("ResourceManagerCache");
98 cache = new Hashtable ();
99 AppDomain.CurrentDomain.SetData ("ResourceManagerCache", cache);
105 AppDomain.CurrentDomain.SetData ("ResourceManagerCache", value);
109 // Timeout is not supported in GH
110 internal bool CheckIfTimeout (DateTime t)
115 internal bool TimeoutPossible
120 internal void BeginTimeoutPossible ()
124 internal void EndTimeoutPossible ()
128 internal void SetWorkerRequest (HttpWorkerRequest wr) {
130 Request.SetWorkerRequest (wr);
131 Response.SetWorkerRequest (wr);
134 Page _currentHandlerInternal;
135 internal Page CurrentHandlerInternal
137 get { return _currentHandlerInternal; }
138 set { _currentHandlerInternal = value; }