This commit is contained in:
Michael Nolan
2022-04-23 13:25:45 -05:00
parent 620abb15e4
commit ccdcf0b8f6
3 changed files with 363 additions and 15 deletions
+73 -2
View File
@@ -7,6 +7,9 @@ namespace Tesses.WebServer
{
public class ServerContext
{
/// <summary>
/// Method (ex GET, POST, HEAD)
/// </summary>
public string Method { get; set; }
public ServerContext(string method,Stream strm,string path,Dictionary<string,List<string>> headers)
{
@@ -15,6 +18,7 @@ namespace Tesses.WebServer
RequestHeaders = headers;
ResponseHeaders = new Dictionary<string, List<string>>();
QueryParams = new Dictionary<string, List<string>>();
RawUrl=path;
StatusCode = 200;
// /joel/path/luigi?local=jim&john_surname=connor&demi_surname=lovato&local=tim
@@ -24,6 +28,7 @@ namespace Tesses.WebServer
if (splitUrl.Length > 0)
{
UrlPath = splitUrl[0];
OriginalUrlPath=splitUrl[0];
if (splitUrl.Length == 2)
{
//local=jim&john_surname=connor&demi_surname=lovato&local=tim
@@ -38,6 +43,9 @@ namespace Tesses.WebServer
}
}
/// <summary>
/// Reset query parms (If api sets them)
/// </summary>
public void ResetQueryParms()
{
QueryParams.Clear();
@@ -67,14 +75,77 @@ namespace Tesses.WebServer
return Server.Address.ToString();
}
string q_parm;
/// <summary>
/// the /somepath/file?s=42&joel=file relative to Mount
/// </summary>
public string UrlAndQuery {get {
if(!string.IsNullOrWhiteSpace(q_parm))
{
return UrlPath + "?" + q_parm;
}
return UrlPath;
}}
/// <summary>
/// Original Url Path
/// </summary>
/// <value></value>
public string OriginalUrlPath {get; private set;}
/// <summary>
/// Original Url path (includes query)
/// </summary>
/// <value></value>
public string RawUrl {get;private set;}
/// <summary>
/// Query parms string only
/// </summary>
public string QueryParamsString {get {return q_parm;}}
/// <summary>
/// Server ip
/// </summary>
public IPEndPoint Server { get; set; }
/// <summary>
/// Client ip
/// </summary>
public IPEndPoint Client { get; set; }
/// <summary>
/// Host name
/// </summary>
/// <returns></returns>
public string Host { get { return get_host(); } }
/// <summary>
/// Url path (can be eet by Moutable)
/// </summary>
public string UrlPath { get; set; }
/// <summary>
/// Query Params
/// </summary>
public Dictionary<string,List<string>> QueryParams { get; set; }
/// <summary>
/// Request headers
/// </summary>
public Dictionary<string,List<string>> RequestHeaders { get; set; }
/// <summary>
/// Response headers
/// </summary>
public Dictionary<string,List<string>> ResponseHeaders { get; set; }
/// <summary>
/// TCP Stream for http server
/// </summary>
public Stream NetworkStream { get; set; }
public int StatusCode { get; internal set; }
/// <summary>
/// Status code for resource
/// </summary>
public int StatusCode { get; set; }
}
}
}