Added BasicAuth, HostName Server, HTTPS (Maybe)
This commit is contained in:
@@ -14,8 +14,7 @@ namespace Tesses.WebServer
|
||||
NetworkStream = strm;
|
||||
RequestHeaders = headers;
|
||||
ResponseHeaders = new Dictionary<string, List<string>>();
|
||||
var qp = new Dictionary<string, List<string>>();
|
||||
|
||||
QueryParams = new Dictionary<string, List<string>>();
|
||||
StatusCode = 200;
|
||||
|
||||
// /joel/path/luigi?local=jim&john_surname=connor&demi_surname=lovato&local=tim
|
||||
@@ -29,24 +28,35 @@ namespace Tesses.WebServer
|
||||
{
|
||||
//local=jim&john_surname=connor&demi_surname=lovato&local=tim
|
||||
//we want to split on &
|
||||
foreach(var item in splitUrl[1].Split(new char[] { '&'},StringSplitOptions.RemoveEmptyEntries))
|
||||
q_parm = splitUrl[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
q_parm = "";
|
||||
}
|
||||
ResetQueryParms();
|
||||
}
|
||||
|
||||
}
|
||||
public void ResetQueryParms()
|
||||
{
|
||||
QueryParams.Clear();
|
||||
foreach (var item in q_parm.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
//Console.WriteLine(item);
|
||||
var itemSplit = item.Split(new char[] { '=' }, 2);
|
||||
if (itemSplit.Length > 0)
|
||||
{
|
||||
string key = itemSplit[0];
|
||||
string value = "";
|
||||
if (itemSplit.Length == 2)
|
||||
{
|
||||
//Console.WriteLine(item);
|
||||
var itemSplit = item.Split(new char[] { '=' }, 2);
|
||||
if(itemSplit.Length > 0)
|
||||
{
|
||||
string key = itemSplit[0];
|
||||
string value = "";
|
||||
if(itemSplit.Length ==2)
|
||||
{
|
||||
value = itemSplit[1];
|
||||
}
|
||||
qp.Add(key, value);
|
||||
}
|
||||
value = itemSplit[1];
|
||||
}
|
||||
QueryParams.Add(key, value);
|
||||
}
|
||||
}
|
||||
QueryParams = qp;
|
||||
|
||||
}
|
||||
private string get_host()
|
||||
{
|
||||
@@ -54,8 +64,11 @@ namespace Tesses.WebServer
|
||||
{
|
||||
return RequestHeaders.GetFirst("Host");
|
||||
}
|
||||
return "";
|
||||
return Server.Address.ToString();
|
||||
}
|
||||
string q_parm;
|
||||
public IPEndPoint Server { get; set; }
|
||||
public IPEndPoint Client { get; set; }
|
||||
public string Host { get { return get_host(); } }
|
||||
public string UrlPath { get; set; }
|
||||
public Dictionary<string,List<string>> QueryParams { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user