Added Server Sent Events
This commit is contained in:
@@ -79,6 +79,53 @@ internal class SizedStream : Stream
|
||||
/// Method (ex GET, POST, HEAD)
|
||||
/// </summary>
|
||||
public string Method { get; set; }
|
||||
|
||||
Func<bool> isConnected;
|
||||
|
||||
public bool Connected {
|
||||
get{
|
||||
if(isConnected != null)
|
||||
{
|
||||
return isConnected();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public ServerContext(string method,Stream strm,string path,Dictionary<string,List<string>> headers,Func<bool> isConnected)
|
||||
{
|
||||
Method = method;
|
||||
NetworkStream = strm;
|
||||
RequestHeaders = headers;
|
||||
ResponseHeaders = new Dictionary<string, List<string>>();
|
||||
QueryParams = new Dictionary<string, List<string>>();
|
||||
ResponseHeaders.Add("Server","Tesses.WebServer");
|
||||
ResponseHeaders.Add("Connection","close");
|
||||
RawUrl=path;
|
||||
StatusCode = 200;
|
||||
|
||||
// /joel/path/luigi?local=jim&john_surname=connor&demi_surname=lovato&local=tim
|
||||
|
||||
string[] splitUrl = path.Split(new char[] { '?' }, 2);
|
||||
|
||||
if (splitUrl.Length > 0)
|
||||
{
|
||||
UrlPath = splitUrl[0];
|
||||
OriginalUrlPath=splitUrl[0];
|
||||
if (splitUrl.Length == 2)
|
||||
{
|
||||
//local=jim&john_surname=connor&demi_surname=lovato&local=tim
|
||||
//we want to split on &
|
||||
q_parm = splitUrl[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
q_parm = "";
|
||||
}
|
||||
ResetQueryParms();
|
||||
}
|
||||
|
||||
this.isConnected=isConnected;
|
||||
}
|
||||
public ServerContext(string method,Stream strm,string path,Dictionary<string,List<string>> headers)
|
||||
{
|
||||
Method = method;
|
||||
@@ -111,7 +158,7 @@ internal class SizedStream : Stream
|
||||
}
|
||||
ResetQueryParms();
|
||||
}
|
||||
|
||||
isConnected=null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Reset query parms (If api sets them)
|
||||
|
||||
Reference in New Issue
Block a user