+2002-04-11 Patrik Torstensson <patrik.torstensson@labs2.com>
+
+ * HttpException.cs: 95% ready, only windows dependent code left
+ * HttpFileCollection.cs: Finished.
+ * HttpRequest.cs: Minor fixes and fixed signature problems
+ * HttpResponse.cs: Implementation of missing methods and signature problems
+ * HttpResponseHeader.cs: Fixed signature problems
+ * HttpRuntime.cs: Fixed signature problems
+ * HttpServerUtility.cs: Added support for HttpApplication
+ * HttpSessionState.cs: Fixed signature issues
+ * HttpUtility.cs: fixed signature issues
+ * HttpValueCollection.cs: Support for cookie parsing and fixed signature issues
+ * HttpWorkerRequest.cs: Fixed small signature issue
+ * HttpWriter.cs: Fixed signature issue
+ * HttpApplication.cs: Basic implementation
+ * HttpApplicationState.cs: Small fixes to support major change comming up
+ * HttpBrowserCapabilities.cs: Added Type method
+ * HttpClientCertificate.cs: Almost ready, needs to parse certificate.
+ * HttpContext.cs: Fixed signature issues and added last methods.
+ * HttpCookie.cs: Full implementation
+ * HttpCookieCollection.cs: Full implementation
+ * TraceContext.cs: Methods implemented.
+ * HttpPostedFile.cs: Placeholder
+ * HttpStaticObjectsCollection.cs: Placeholder
+ * HttpModuleCollection.cs: Ready, will be used during the major revamp.
+
+ * Fixed a number of other small signature problems also (class status page)
+
+
2002-04-10 Patrik Torstensson <patrik.torstensson@labs2.com>
* HttpWorkerRequest.EndOfSendNotification.cs Removed (included in WorkerRequest)
// Patrik Torstensson (Patrik.Torstensson@labs2.com)\r
//\r
using System;\r
+using System.ComponentModel;\r
\r
namespace System.Web {\r
[MonoTODO()]\r
- public class HttpApplication {\r
+ public class HttpApplication : IHttpAsyncHandler, IHttpHandler, IComponent, IDisposable {\r
+ private bool _CompleteRequest;\r
+\r
+ private HttpContext _Context;\r
+ private HttpContext _OverrideContext;\r
+ \r
+ private bool _InPreRequestResponseMode;\r
+\r
+ private ISite _Site;\r
+ private HttpModuleCollection _ModuleCollection;\r
+ private HttpSessionState _Session;\r
+\r
+ public event EventHandler AcquireRequestState;\r
+ public event EventHandler AuthenticateRequest;\r
+ public event EventHandler AuthorizeRequest;\r
+ public event EventHandler BeginRequest;\r
+ public event EventHandler Disposed;\r
+ public event EventHandler EndRequest;\r
+ public event EventHandler Error;\r
+ public event EventHandler PostRequestHandlerExecute;\r
+ public event EventHandler PreRequestHandlerExecute;\r
+ public event EventHandler PreSendRequestContent;\r
+ public event EventHandler PreSendRequestHeaders;\r
+ public event EventHandler ReleaseRequestState;\r
+ public event EventHandler ResolveRequestCache;\r
+ public event EventHandler UpdateRequestCache;\r
+\r
+ [MonoTODO()]\r
public HttpApplication() {\r
- //\r
- // TODO: Add constructor logic here\r
- //\r
+ // Init HTTP context and the methods from HttpRuntime....\r
+ }\r
+\r
+ internal void ClearError() {\r
+ // Called from Server Utility\r
+ }\r
+\r
+ public HttpContext Context {\r
+ get {\r
+ if (null != _OverrideContext) {\r
+ return _OverrideContext;\r
+ }\r
+\r
+ return _Context;\r
+ }\r
+ }\r
+\r
+ public HttpModuleCollection Modules {\r
+ get {\r
+ if (null == _ModuleCollection) {\r
+ _ModuleCollection = new HttpModuleCollection();\r
+ }\r
+\r
+ return _ModuleCollection;\r
+ }\r
+ }\r
+\r
+ public HttpRequest Request {\r
+ get {\r
+ if (null != _Context && (!_InPreRequestResponseMode)) {\r
+ return _Context.Request;\r
+ }\r
+\r
+ throw new HttpException("Cant get request object");\r
+ }\r
+ }\r
+\r
+ public HttpResponse Response {\r
+ get {\r
+ if (null != _Context && (!_InPreRequestResponseMode)) {\r
+ return _Context.Response;\r
+ }\r
+\r
+ throw new HttpException("Cant get response object");\r
+ }\r
+ }\r
+\r
+ public HttpServerUtility Server {\r
+ get {\r
+ if (null != _Context) {\r
+ return _Context.Server;\r
+ }\r
+\r
+ return new HttpServerUtility(this);\r
+ }\r
+ }\r
+\r
+ public HttpSessionState Session {\r
+ get {\r
+ if (null != _Session) {\r
+ return _Session;\r
+ }\r
+\r
+ if (null != _Context && null != _Context.Session) {\r
+ return _Context.Session;\r
+ }\r
+\r
+ throw new HttpException("Failed to get session object");\r
+ }\r
+ }\r
+\r
+ public virtual string GetVaryByCustomString(HttpContext context, string custom) {\r
+ if (custom.ToLower() == "browser") {\r
+ return context.Request.Browser.Type;\r
+ }\r
+\r
+ return string.Empty;\r
+ }\r
+\r
+ [MonoTODO()]\r
+ IAsyncResult IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ [MonoTODO()]\r
+ void IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ [MonoTODO()]\r
+ void IHttpHandler.ProcessRequest(HttpContext context) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ bool IHttpHandler.IsReusable {\r
+ get {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
+\r
+ public ISite Site {\r
+ get {\r
+ return _Site;\r
+ }\r
+\r
+ set {\r
+ _Site = value;\r
+ }\r
+ }\r
+\r
+ public void CompleteRequest() {\r
+ _CompleteRequest = true;\r
+ }\r
+\r
+ [MonoTODO("Cleanup")]\r
+ public virtual void Dispose() {\r
+ \r
+ }\r
+\r
+ public virtual void Init() {\r
}\r
}\r
}\r
// Patrik Torstensson (Patrik.Torstensson@labs2.com)\r
//\r
using System;\r
+using System.Web;\r
+using System.Collections.Specialized;\r
\r
namespace System.Web {\r
\r
- [MonoTODO()]\r
- public class HttpApplicationState {\r
+ public class HttpApplicationState : NameObjectCollectionBase {\r
[MonoTODO()]\r
internal HttpApplicationState() {\r
- //\r
- // TODO: Add constructor logic here\r
- //\r
}\r
}\r
}\r
// TODO: Add constructor logic here\r
//\r
}\r
+\r
+ [MonoTODO()]\r
+ public string Type {\r
+ get {\r
+ throw new NotImplementedException();\r
+ }\r
+ }\r
}\r
}\r
// Patrik Torstensson (Patrik.Torstensson@labs2.com)\r
//\r
using System;\r
+using System.Web;\r
+using System.Collections.Specialized;\r
\r
namespace System.Web {\r
[MonoTODO()]\r
- public class HttpClientCertificate {\r
- public HttpClientCertificate() {\r
- //\r
- // TODO: Add constructor logic here\r
- //\r
+ public class HttpClientCertificate : NameObjectCollectionBase {\r
+ private HttpContext _Context;\r
+ private byte [] _BinaryIssuer;\r
+ private int _CertEncoding;\r
+ private byte [] _Certificate;\r
+ private string _Cookie;\r
+ private int _Flags;\r
+ private string _Issuer; \r
+ private int _KeySize;\r
+ private byte [] _PublicKey;\r
+ private int _SecretKeySize;\r
+ private string _SerialNumber;\r
+ private string _ServerIssuer;\r
+ private string _ServerSubject;\r
+ private string _Subject;\r
+\r
+ private DateTime _ValidFrom;\r
+ private DateTime _ValidTo;\r
+\r
+ [MonoTODO("Decode ceritificate from Server variables.. CGI standard?")]\r
+ internal HttpClientCertificate(HttpContext Context) {\r
+ _Context = Context;\r
+ _Flags = 0;\r
+ }\r
+\r
+ public byte [] BinaryIssuer {\r
+ get {\r
+ return _BinaryIssuer;\r
+ }\r
+ }\r
+\r
+ public int CertEncoding {\r
+ get {\r
+ return _CertEncoding;\r
+ }\r
+ }\r
+\r
+ public byte [] Certificate {\r
+ get {\r
+ return _Certificate;\r
+ }\r
+ }\r
+\r
+ public string Cookie {\r
+ get {\r
+ return _Cookie;\r
+ }\r
+ }\r
+\r
+ public int Flags {\r
+ get {\r
+ return _Flags;\r
+ }\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public bool IsPresent {\r
+ get {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public string Issuer {\r
+ get {\r
+ return _Issuer;\r
+ }\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public bool IsValid {\r
+ get {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public int KeySize {\r
+ get {\r
+ return _KeySize;\r
+ }\r
+ }\r
+\r
+ public byte [] PublicKey {\r
+ get {\r
+ return _PublicKey;\r
+ }\r
+ }\r
+\r
+ public int SecretKeySize {\r
+ get {\r
+ return _SecretKeySize;\r
+ }\r
+ }\r
+\r
+ public string SerialNumber {\r
+ get {\r
+ return _SerialNumber;\r
+ }\r
+ }\r
+\r
+ public string ServerIssuer {\r
+ get {\r
+ return _ServerIssuer;\r
+ }\r
+ }\r
+\r
+ public string ServerSubject { \r
+ get {\r
+ return _ServerSubject;\r
+ }\r
+ }\r
+\r
+ public string Subject { \r
+ get {\r
+ return _Subject;\r
+ }\r
+ }\r
+\r
+ public DateTime ValidFrom {\r
+ get {\r
+ return _ValidFrom;\r
+ }\r
+ }\r
+\r
+ public DateTime ValidUntil {\r
+ get {\r
+ return ValidUntil;\r
+ }\r
}\r
}\r
}\r
\r
namespace System.Web {\r
[MonoTODO("HttpContext - Should also keep the script timeout info")]\r
- public class HttpContext : IServiceProvider {\r
+ public sealed class HttpContext : IServiceProvider {\r
private Exception [] _arrExceptions;\r
\r
private HttpResponse _oResponse;\r
get {\r
throw new NotImplementedException();\r
}\r
+\r
+ set {\r
+ throw new NotImplementedException();\r
+ }\r
}\r
\r
public DateTime Timestamp {\r
-//\r
-// System.Web.HttpCookie.cs\r
+// \r
+// System.Web.HttpCookie\r
//\r
// Author:\r
-// Bob Smith <bob@thestuff.net>\r
-//\r
-// (C) Bob Smith\r
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)\r
//\r
-\r
using System;\r
+using System.Text;\r
+using System.Web;\r
using System.Collections.Specialized;\r
\r
namespace System.Web {\r
public sealed class HttpCookie {\r
- private string _name;\r
- private string _value = null;\r
- private string _domain; //TODO: default to some pref.\r
- private DateTime _expires;\r
- private string _path; //TODO: default is the current request path.\r
- private bool _secure = false;\r
+ private string _Name;\r
+ private string _Value;\r
+ private string _Domain;\r
+ private DateTime _Expires;\r
+ private bool _ExpiresSet;\r
+ private string _Path; \r
+ private bool _Secure = false;\r
+ \r
+ private HttpValueCollection _Values;\r
+\r
+ internal HttpCookie() {\r
+ _Path = "/";\r
+ }\r
+\r
public HttpCookie(string name) {\r
- _name = name;\r
+ _Path = "/";\r
+ _Name = name;\r
}\r
+\r
public HttpCookie(string name, string value) {\r
- _name = name;\r
- _value = value;\r
+ _Name = name;\r
+ _Value = value;\r
}\r
+\r
+ HttpResponseHeader GetCookieHeader() {\r
+ StringBuilder oSetCookie = new StringBuilder();\r
+\r
+ if (null != _Name && _Name.Length > 0) {\r
+ oSetCookie.Append(_Name);\r
+ oSetCookie.Append("=");\r
+ }\r
+\r
+ if (null != _Values) {\r
+ oSetCookie.Append(_Values.ToString(false));\r
+ } else if (null != _Value) {\r
+ oSetCookie.Append(_Value);\r
+ }\r
+\r
+ if (null != _Domain && _Domain.Length > 0) {\r
+ oSetCookie.Append("; domain=");\r
+ oSetCookie.Append(_Domain);\r
+ }\r
+\r
+ if (null != _Path && Path.Length > 0) {\r
+ oSetCookie.Append("; path=");\r
+ oSetCookie.Append(_Path);\r
+ }\r
+\r
+ if (_Secure) {\r
+ oSetCookie.Append("; secure");\r
+ }\r
+\r
+ return new HttpResponseHeader(HttpWorkerRequest.HeaderSetCookie, oSetCookie.ToString());\r
+ }\r
+\r
public string Domain {\r
get {\r
- return _domain;\r
+ return _Domain;\r
}\r
set {\r
- _domain = value;\r
+ _Domain = value;\r
}\r
}\r
+\r
public DateTime Expires {\r
get {\r
- return _expires;\r
+ if (!_ExpiresSet) {\r
+ return DateTime.MinValue;\r
+ }\r
+\r
+ return _Expires;\r
}\r
+\r
set {\r
- _expires = value;\r
+ _ExpiresSet = true;\r
+ _Expires = value;\r
}\r
}\r
+\r
public bool HasKeys {\r
get {\r
- return false; //TODO\r
+ return Values.HasKeys();\r
}\r
}\r
+\r
public string this[string key] {\r
- //TODO: get/set subcookie.\r
- get {return "";}\r
- set {}\r
+ get {\r
+ return Values[key];\r
+ }\r
+ \r
+ set {\r
+ Values[key] = value;\r
+ }\r
}\r
+\r
public string Name {\r
get {\r
- return _name;\r
+ return _Name;\r
}\r
+\r
set {\r
- _name = value;\r
+ _Name = value;\r
}\r
}\r
+\r
public string Path {\r
get {\r
- return _path;\r
+ return _Path;\r
}\r
+\r
set {\r
- _path = value;\r
+ _Path = value;\r
}\r
}\r
+\r
public bool Secure {\r
get {\r
- return _secure;\r
+ return _Secure;\r
}\r
set {\r
- _secure = value;\r
+ _Secure = value;\r
}\r
}\r
+\r
public string Value {\r
get {\r
- return _value;\r
+ if (null != _Values) {\r
+ return _Values.ToString(false);\r
+ }\r
+ \r
+ return _Value;\r
}\r
set {\r
- _value = value;\r
+ if (null != _Values) {\r
+ _Values.Reset();\r
+ _Values.Add(null, value);\r
+ return;\r
+ }\r
+\r
+ _Value = value;\r
}\r
}\r
+\r
public NameValueCollection Values {\r
- //TODO\r
- get {return null;}\r
+ get {\r
+ if (null == _Values) {\r
+ _Values = new HttpValueCollection();\r
+ if (null != _Value) {\r
+ // Do we have multiple keys\r
+ if (_Value.IndexOf("&") >= 0 || _Value.IndexOf("=") >= 0) {\r
+ _Values.FillFromCookieString(_Value);\r
+ } else {\r
+ _Values.Add(null, _Value);\r
+ }\r
+\r
+ _Value = null;\r
+ }\r
+ }\r
+\r
+ return _Values;\r
+ }\r
}\r
}\r
}\r
-//\r
-// System.Web.HttpCookieCollection.cs\r
+// \r
+// System.Web.HttpCookieCollection\r
//\r
// Author:\r
-// Bob Smith <bob@thestuff.net>\r
-//\r
-// (C) Bob Smith\r
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)\r
+// (First impl Bob Smith <bob@thestuff.net>)\r
//\r
\r
using System;\r
+using System.Web;\r
using System.Collections.Specialized;\r
\r
namespace System.Web {\r
public sealed class HttpCookieCollection : NameObjectCollectionBase {\r
- public HttpCookieCollection() {}\r
- public string[] AllKeys {\r
+ private HttpCookie [] _AllCookies;\r
+ private string [] _AllKeys;\r
+ \r
+ private HttpResponse _Response;\r
+\r
+ internal HttpCookieCollection(HttpResponse Response, bool ReadOnly) : base() {\r
+ _Response = Response;\r
+ IsReadOnly = ReadOnly;\r
+ }\r
+\r
+ public HttpCookieCollection() {\r
+ }\r
+ \r
+ public string [] AllKeys {\r
get {\r
- return this.BaseGetAllKeys();\r
+ if (null == _AllKeys) {\r
+ _AllKeys = BaseGetAllKeys();\r
+ }\r
+\r
+ return _AllKeys;\r
}\r
}\r
+ \r
public HttpCookie this[int index] {\r
get {\r
- return (HttpCookie)(this.BaseGet(index));\r
+ return Get(index);\r
}\r
}\r
+ \r
public HttpCookie this[string name] {\r
get {\r
- return (HttpCookie)(this.BaseGet(name));\r
+ return Get(name);\r
}\r
}\r
+\r
public void Add(HttpCookie cookie) {\r
- this.BaseAdd(cookie.Name, cookie);\r
+ if (null != _Response) {\r
+ _Response.GoingToChangeCookieColl();\r
+ }\r
+\r
+ // empy performance cache\r
+ _AllCookies = null;\r
+ _AllKeys = null;\r
+\r
+ BaseAdd(cookie.Name, cookie);\r
+\r
+ if (null != _Response) {\r
+ _Response.OnCookieAdd(cookie);\r
+ }\r
}\r
+\r
public void Clear() {\r
+ _AllCookies = null;\r
+ _AllKeys = null;\r
this.BaseClear();\r
}\r
+\r
public void CopyTo(Array dest, int index) {\r
- int i;\r
- HttpCookie cookie;\r
- for(i=0; i<this.Count; i++) {\r
- cookie=this[i];\r
- dest.SetValue(new HttpCookie(cookie.Name, cookie.Value), index+i);\r
+ if (null == _AllCookies) {\r
+ _AllCookies = new HttpCookie[Count];\r
+\r
+ for (int i = 0; i != Count; i++) {\r
+ _AllCookies[i] = Get(i);\r
+ }\r
+ }\r
+\r
+ if (null != _AllCookies) {\r
+ _AllCookies.CopyTo(dest, index);\r
}\r
}\r
+\r
+ public HttpCookie Get(int index) {\r
+ return (HttpCookie) BaseGet(index);\r
+ }\r
+\r
+ public HttpCookie Get(string name) {\r
+ HttpCookie oRet = (HttpCookie) BaseGet(name);\r
+ if (null == oRet && _Response != null) {\r
+ _AllCookies = null;\r
+ _AllKeys = null;\r
+\r
+ _Response.GoingToChangeCookieColl();\r
+ \r
+ oRet = new HttpCookie(name);\r
+ BaseAdd(name, oRet);\r
+\r
+ _Response.OnCookieAdd(oRet);\r
+ }\r
+\r
+ return oRet;\r
+ }\r
+\r
public string GetKey(int index) {\r
return this.BaseGetKey(index);\r
}\r
+\r
public void Remove(string name) {\r
+ if (null != _Response) {\r
+ _Response.GoingToChangeCookieColl();\r
+ }\r
+\r
+ _AllCookies = null;\r
+ _AllKeys = null;\r
this.BaseRemove(name);\r
+ \r
+ if (null != _Response) {\r
+ _Response.ChangedCookieColl();\r
+ }\r
}\r
+\r
public void Set(HttpCookie cookie) {\r
+ if (null != _Response) {\r
+ _Response.GoingToChangeCookieColl();\r
+ }\r
+\r
+ _AllCookies = null;\r
+ _AllKeys = null;\r
this.BaseSet(cookie.Name, cookie);\r
+\r
+ if (null != _Response) {\r
+ _Response.ChangedCookieColl();\r
+ }\r
}\r
}\r
}\r
[MonoTODO("This class contains a lot of windows specific methods, solve this.. :)")]\r
public class HttpException : ExternalException {\r
private int _HttpCode;\r
+ private int _HR;\r
+\r
+ public HttpException() : base() {\r
+ }\r
\r
public HttpException(string sMessage) : base(sMessage) {\r
}\r
_HttpCode = iHttpCode;\r
}\r
\r
+ public HttpException(int iHttpCode, string sMessage, int iHR) : base(sMessage) {\r
+ _HttpCode = iHttpCode;\r
+ _HR = iHR;\r
+ }\r
+\r
+ public HttpException(string sMessage, int iHR) : base(sMessage) {\r
+ _HR = iHR;\r
+ }\r
+\r
public HttpException(int iHttpCode, string sMessage, Exception InnerException) : base(sMessage, InnerException) {\r
_HttpCode = iHttpCode;\r
}\r
+ \r
+ [MonoTODO("Should get an correct html message depending on error type")]\r
+ public string GetHtmlErrorMessage() {\r
+ throw new NotImplementedException();\r
+ }\r
\r
+ [MonoTODO("Check error type and Set the correct error code")]\r
public int GetHttpCode() {\r
return _HttpCode;\r
}\r
+\r
+ [MonoTODO("Get the last error code")]\r
+ public static HttpException CreateFromLastError(string Message) {\r
+ return new HttpException(Message);\r
+ }\r
+\r
+\r
}\r
}\r
// Patrik Torstensson (Patrik.Torstensson@labs2.com)\r
//\r
using System;\r
+using System.Collections.Specialized;\r
\r
namespace System.Web {\r
- [MonoTODO()]\r
- public class HttpFileCollection {\r
- public HttpFileCollection() {\r
- //\r
- // TODO: Add constructor logic here\r
- //\r
+ public sealed class HttpFileCollection : NameObjectCollectionBase {\r
+ private HttpPostedFile [] _AllFiles;\r
+ private string [] _AllKeys;\r
+\r
+ internal HttpFileCollection() : base() {\r
+ }\r
+\r
+ internal void AddFile(string name, HttpPostedFile file) {\r
+ _AllFiles = null;\r
+ _AllKeys = null;\r
+\r
+ BaseAdd(name, file);\r
+ }\r
+\r
+ public void CopyTo(Array Dest, int index) {\r
+ if (null == _AllFiles) {\r
+ _AllFiles = new HttpPostedFile[Count];\r
+ for (int i = 0; i != Count; i++) {\r
+ _AllFiles[i] = Get(i);\r
+ }\r
+ }\r
+\r
+ if (null != _AllFiles) {\r
+ _AllFiles.CopyTo(Dest, index);\r
+ }\r
+ }\r
+\r
+ public HttpPostedFile Get(string Name) {\r
+ return (HttpPostedFile) BaseGet(Name);\r
+ }\r
+\r
+ public HttpPostedFile Get(int index) {\r
+ return (HttpPostedFile) BaseGet(index);\r
+ }\r
+\r
+ public string GetKey(int index) {\r
+ return BaseGetKey(index);\r
+ }\r
+\r
+ public string [] AllKeys {\r
+ get {\r
+ if (null == _AllKeys) {\r
+ _AllKeys = BaseGetAllKeys();\r
+ }\r
+\r
+ return _AllKeys;\r
+ }\r
+ }\r
+ \r
+ public HttpPostedFile this [string name] {\r
+ get {\r
+ return Get(name);\r
+ }\r
+ }\r
+\r
+ public HttpPostedFile this [int index] {\r
+ get {\r
+ return Get(index);\r
+ }\r
}\r
+ \r
}\r
}\r
using System.Text;\r
\r
namespace System.Web {\r
- //-- Methods from HttpRequest not implemented\r
- // public HttpFileCollection Files {get;}\r
- // public HttpBrowserCapabilities Browser {get; set;}\r
- // public HttpClientCertificate ClientCertificate {get;}\r
- // public string ApplicationPath {get;}\r
- // public HttpCookieCollection Cookies {get;}\r
- // public Stream Filter {get; set;}\r
- // public string MapPath(string virtualPath, string baseVirtualDir, bool allowCrossAppMapping);\r
- // public string MapPath(string virtualPath);\r
- // public int [] MapImageCoordinates(string imageFieldName);\r
- // public string FilePath {get;}\r
- // public Uri UrlReferrer \r
-\r
[MonoTODO("Review security in all path access function")]\r
- public class HttpRequest {\r
+ public sealed class HttpRequest {\r
private string [] _arrAcceptTypes;\r
private string [] _arrUserLanguages;\r
\r
\r
private HttpWorkerRequest _WorkerRequest;\r
private HttpRequestStream _oInputStream;\r
+ private HttpClientCertificate _ClientCert;\r
\r
private HttpValueCollection _oServerVariables;\r
private HttpValueCollection _oHeaders;\r
}\r
}\r
\r
- [MonoTODO()]\r
public HttpClientCertificate ClientCertificate {\r
get {\r
- throw new NotImplementedException();\r
+ if (null == _ClientCert) {\r
+ _ClientCert = new HttpClientCertificate(_oContext);\r
+ }\r
+\r
+ return _ClientCert;\r
}\r
}\r
\r
\r
return _sRequestType;\r
}\r
+\r
+ set {\r
+ _sRequestType = value;\r
+ }\r
}\r
\r
\r
private long _lContentLength;\r
private int _iStatusCode;\r
\r
+ private bool _ClientDisconnected;\r
+\r
private string _sContentType;\r
private string _sCacheControl;\r
private string _sTransferEncoding;\r
private string _sCharset;\r
private string _sStatusDescription;\r
\r
+ private HttpCookieCollection _Cookies;\r
private HttpCachePolicy _CachePolicy;\r
\r
private Encoding _ContentEncoding;\r
\r
private HttpWorkerRequest _WorkerRequest;\r
\r
- public HttpResponse(HttpWorkerRequest WorkerRequest, HttpContext Context) {\r
+ [MonoTODO("Verify that this really works")]\r
+ internal HttpResponse(TextWriter output) {\r
+ _bBuffering = true;\r
+ _bFlushing = false;\r
+ _bHeadersSent = false;\r
+\r
+ _Headers = new ArrayList();\r
+\r
+ _sContentType = "text/html";\r
+\r
+ _iStatusCode = 200;\r
+ _sCharset = null;\r
+ _sCacheControl = null;\r
+\r
+ _lContentLength = 0;\r
+ _bSuppressContent = false;\r
+ _bSuppressHeaders = false;\r
+ _bClientDisconnected = false;\r
+\r
+ _bChunked = false;\r
+\r
+ _TextWriter = output;\r
+ }\r
+\r
+ internal HttpResponse(HttpWorkerRequest WorkerRequest, HttpContext Context) {\r
_Context = Context;\r
_WorkerRequest = WorkerRequest;\r
\r
oHeaders.Add(new HttpResponseHeader(HttpWorkerRequest.HeaderTransferEncoding, _sTransferEncoding));\r
}\r
\r
+ // TODO: Add Cookie headers..\r
+\r
return oHeaders;\r
}\r
\r
_bHeadersSent = true;\r
}\r
\r
+ public string Status {\r
+ get {\r
+ return StatusCode.ToString() + " " + StatusDescription;\r
+ }\r
+\r
+ set {\r
+ string sMsg = "OK";\r
+ int iCode = 200;\r
+\r
+ try {\r
+ iCode = Int32.Parse(value.Substring(0, value.IndexOf(' ')));\r
+ sMsg = value.Substring(value.IndexOf(' ') + 1);\r
+ }\r
+ catch(Exception) {\r
+ throw new HttpException("Invalid status string");\r
+ }\r
+\r
+ StatusCode = iCode;\r
+ StatusDescription = sMsg;\r
+ }\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public void AddCacheItemDependencies(ArrayList cacheKeys) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public void AddCacheItemDependency(string cacheKey) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public void AddFileDependencies(ArrayList filenames) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public void AddFileDependency(string filename) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ public void AddHeader(string name, string value) {\r
+ AppendHeader(name, value);\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public void AppendCookie(HttpCookie cookie) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public void AppendToLog(string param) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public string ApplyAppPathModifier(string virtualPath) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
public bool Buffer {\r
get {\r
return BufferOutput;\r
}\r
}\r
\r
- [MonoTODO("Set status in the cache policy")]\r
public HttpCookieCollection Cookies {\r
get {\r
- throw new NotImplementedException();\r
+ if (null == _Cookies) {\r
+ _Cookies = new HttpCookieCollection(this, false);\r
+ }\r
+ return _Cookies;\r
}\r
}\r
\r
}\r
}\r
\r
- [MonoTODO("Set expires in the cache policy")]\r
- public int ExpiresAbsolut {\r
+ [MonoTODO("Set expiresabsolute in the cache policy")]\r
+ public int ExpiresAbsolute {\r
get {\r
throw new NotImplementedException();\r
}\r
throw new NotImplementedException();\r
}\r
}\r
+\r
+ public Stream Filter {\r
+ get {\r
+ if (_Writer != null) {\r
+ return _Writer.GetActiveFilter();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ set {\r
+ if (_Writer == null) {\r
+ throw new HttpException("Filtering is not allowed");\r
+ }\r
+\r
+ _Writer.ActivateFilter(value);\r
+ }\r
+ }\r
+\r
+ public bool IsClientConnected {\r
+ get {\r
+ if (_ClientDisconnected) {\r
+ return false;\r
+ }\r
+\r
+ if (null != _WorkerRequest && (!_WorkerRequest.IsClientConnected())) {\r
+ _ClientDisconnected = false;\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+ }\r
+ }\r
\r
public TextWriter Output {\r
get {\r
public void Write(char [] buffer, int index, int count) {\r
_TextWriter.Write(buffer, index, count);\r
}\r
+\r
+ [MonoTODO()]\r
+ public static void RemoveOutputCacheItem(string path) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public void SetCookie(HttpCookie cookie) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ public void WriteFile(string filename) {\r
+ WriteFile(filename, false);\r
+ }\r
+\r
+ [MonoTODO()]\r
+ public void WriteFile(string filename, bool readIntoMemory) {\r
+ throw new NotImplementedException();\r
+ }\r
+ \r
+ [MonoTODO()]\r
+ public void WriteFile(string filename, long offset, long size) {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ [MonoTODO("Should we support fileHandle ptrs?")]\r
+ public void WriteFile(IntPtr fileHandle, long offset, long size) {\r
+ } \r
+\r
+ [MonoTODO()]\r
+ internal void OnCookieAdd(HttpCookie cookie) {\r
+ }\r
+\r
+ [MonoTODO("Do we need this?")]\r
+ internal void OnCookieChange(HttpCookie cookie) {\r
+ }\r
+\r
+ [MonoTODO()]\r
+ internal void GoingToChangeCookieColl() {\r
+ }\r
+\r
+ [MonoTODO()]\r
+ internal void ChangedCookieColl() {\r
+ }\r
}\r
}\r
private string _sValue;\r
private int _iKnowHeaderId;\r
\r
- public HttpResponseHeader(int KnowHeaderId, string value) {\r
+ internal HttpResponseHeader(int KnowHeaderId, string value) {\r
_iKnowHeaderId = KnowHeaderId;\r
_sValue = value;\r
}\r
\r
- public HttpResponseHeader(string header, string value) {\r
+ internal HttpResponseHeader(string header, string value) {\r
_sHeader = header;\r
_sValue = value;\r
}\r
\r
namespace System.Web {\r
[MonoTODO("Make corrent right now this is a simple impl to give us a base for testing... the methods here are not complete or valid")]\r
- public class HttpRuntime {\r
+ public sealed class HttpRuntime {\r
// Security permission helper objects\r
private static IStackWalk appPathDiscoveryStackWalk;\r
private static IStackWalk ctrlPrincipalStackWalk;\r
using System.IO;\r
\r
namespace System.Web {\r
- /// <summary>\r
- /// System.Web.\r
- /// </summary>\r
public sealed class HttpServerUtility {\r
\r
private static string _name = "";\r
\r
private HttpContext _Context;\r
+ private HttpApplication _Application;\r
\r
[MonoTODO()]\r
- public HttpServerUtility(HttpContext Context) {\r
+ internal HttpServerUtility(HttpContext Context) {\r
_Context = Context;\r
}\r
\r
+ [MonoTODO()]\r
+ internal HttpServerUtility(HttpApplication app) {\r
+ _Application = app;\r
+ }\r
+\r
// Properties\r
\r
\r
/// Clears the previous exception.\r
/// </summary>\r
public void ClearError() {\r
- _Context.ClearError();\r
+ if (null != _Context) {\r
+ _Context.ClearError();\r
+ return;\r
+ }\r
+\r
+ if (null != _Application) {\r
+ _Application.ClearError();\r
+ }\r
}\r
\r
\r
/// <param name="path">The virtual path on the Web server. </param>\r
/// <returns>The physical file path that corresponds to path.</returns>\r
public string MapPath(string path) {\r
+ if (null == _Context) {\r
+ throw new HttpException("MapPath is not available");\r
+ }\r
+\r
return _Context.Request.MapPath(path);\r
}\r
\r
[MonoTODO()]\r
public class HttpSessionState {\r
public HttpSessionState() {\r
- //\r
- // TODO: Add constructor logic here\r
- //\r
}\r
}\r
}\r
using System.IO;\r
\r
namespace System.Web {\r
- [MonoTODO()]\r
- public class HttpUtility {\r
+ public sealed class HttpUtility {\r
// private stuff\r
private const string _hex = "0123456789ABCDEF";\r
private const string _chars = "<>;:.?=&@*+%/\\";\r
return dest;\r
}\r
\r
+\r
+\r
public static string UrlEncode(string str) {\r
return UrlDecode(str, Encoding.UTF8);\r
}\r
//\r
using System;\r
using System.Collections.Specialized;\r
+using System.Runtime.Serialization;\r
using System.Text;\r
\r
namespace System.Web {\r
IsReadOnly = ReadOnly;\r
}\r
\r
+ protected HttpValueCollection(SerializationInfo info, StreamingContext context) : base(info, context) {\r
+ }\r
+ \r
// string = header1: value1\r\nheader2: value2\r
internal void FillFromHeaders(string sHeaders, Encoding encoding) {\r
_bHeaders = true;\r
FillFromQueryString(sData, Encoding.UTF8);\r
}\r
\r
+ internal void FillFromCookieString(string sData) {\r
+ FillFromQueryString(sData, Encoding.UTF8);\r
+ }\r
+\r
internal void MakeReadOnly() {\r
IsReadOnly = true;\r
}\r
return null;\r
}\r
\r
+ [CLSCompliant(false)]\r
public virtual string[][] GetUnknownRequestHeaders() {\r
return null;\r
}\r
using System.Text;\r
\r
namespace System.Web {\r
- public class HttpWriter : TextWriter {\r
+ public sealed class HttpWriter : TextWriter {\r
private HttpResponse _Response;\r
\r
private HttpResponseStream _ResponseStream;\r
// (C) Bob Smith
//
-namespace System.Web
-{
- public enum ProcessShutdownReason
- {
- IdleTimeout,
- MemoryLimitExceeded,
- None,
- PingFailed,
- RequestQueueLimit,
- RequestsLimit,
- Timeout,
- Unexpected
- }
+namespace System.Web {
+ public enum ProcessShutdownReason {
+ DeadlockSuspected,
+ IdleTimeout,
+ MemoryLimitExceeded,
+ None,
+ PingFailed,
+ RequestQueueLimit,
+ RequestsLimit,
+ Timeout,
+ Unexpected
+ }
}
\ No newline at end of file
using System;\r
\r
namespace System.Web {\r
- [MonoTODO()]\r
- public class TraceContext {\r
+ public sealed class TraceContext {\r
+ private HttpContext _Context;\r
+ private bool _Enabled;\r
+ private TraceMode _Mode;\r
+\r
public TraceContext(HttpContext Context) {\r
+ _Context = Context;\r
+ _Enabled = true;\r
+ }\r
+\r
+ public bool IsEnabled {\r
+ get {\r
+ return _Enabled;\r
+ }\r
+\r
+ set {\r
+ _Enabled = value;\r
+ }\r
+ }\r
+\r
+ public TraceMode TraceMode {\r
+ get {\r
+ return _Mode;\r
+ }\r
+\r
+ set {\r
+ _Mode = value;\r
+ }\r
+ }\r
+\r
+ public void Warn(string msg) {\r
+ Write(String.Empty, msg, null, true);\r
+ }\r
+\r
+ public void Warn(string category, string msg) {\r
+ Write(category, msg, null, true);\r
+ }\r
+\r
+ public void Warn(string category, string msg, Exception error) {\r
+ Write(category, msg, error, true);\r
+ }\r
+\r
+ public void Write(string msg) {\r
+ Write(String.Empty, msg, null, true);\r
+ }\r
+\r
+ public void Write(string category, string msg) {\r
+ Write(category, msg, null, true);\r
+ }\r
+\r
+ public void Write(string category, string msg, Exception error) {\r
+ Write(category, msg, error, true);\r
+ }\r
+\r
+ [MonoTODO("Save the data into a web dataset directly...")]\r
+ public void Write(string category, string msg, Exception error, bool Warning) {\r
+ throw new NotImplementedException();\r
}\r
}\r
}\r
// (C) Bob Smith
//
-namespace System.Web
-{
- public enum TraceMode
- {
- SortByCategory,
- SortByTime
- }
+namespace System.Web {
+ public enum TraceMode {
+ Default,
+ SortByCategory,
+ SortByTime
+ }
}