slowly but surely figuring out how to store cookies
This commit is contained in:
parent
e6cdfb8521
commit
35ea6c3cd7
@ -13,6 +13,7 @@ public abstract class Control : IWebHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, string> PathVariables { get; } = new Dictionary<string, string>();
|
public Dictionary<string, string> PathVariables { get; } = new Dictionary<string, string>();
|
||||||
|
|
||||||
public Control(Dictionary<string, string>? pathVariables = null)
|
public Control(Dictionary<string, string>? pathVariables = null)
|
||||||
{
|
{
|
||||||
if (pathVariables == null)
|
if (pathVariables == null)
|
||||||
@ -91,7 +92,7 @@ public abstract class Control : IWebHandler
|
|||||||
{
|
{
|
||||||
context.Response.ContentType = "application/xhtml+xml";
|
context.Response.ContentType = "application/xhtml+xml";
|
||||||
|
|
||||||
OnInit(new RenderEventArgs(context.Request, context.Response));
|
OnInit(new RenderEventArgs(context));
|
||||||
|
|
||||||
XmlWriter writer = XmlWriter.Create(context.Response.Stream);
|
XmlWriter writer = XmlWriter.Create(context.Response.Stream);
|
||||||
Render(writer);
|
Render(writer);
|
||||||
|
|||||||
@ -2,14 +2,11 @@ namespace MBS.Web;
|
|||||||
|
|
||||||
public class RenderEventArgs : EventArgs
|
public class RenderEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
public WebContext Context { get; }
|
||||||
|
|
||||||
public WebRequest Request { get; }
|
public RenderEventArgs(WebContext context)
|
||||||
public WebResponse Response { get; }
|
|
||||||
|
|
||||||
public RenderEventArgs(WebRequest request, WebResponse response)
|
|
||||||
{
|
{
|
||||||
Request = request;
|
Context = context;
|
||||||
Response = response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
23
src/lib/MBS.Web/UI/WebControls/AdditionalDetailWidget.cs
Normal file
23
src/lib/MBS.Web/UI/WebControls/AdditionalDetailWidget.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
|
||||||
|
namespace MBS.Web.UI.WebControls;
|
||||||
|
|
||||||
|
public class AdditionalDetailWidget : Container
|
||||||
|
{
|
||||||
|
protected override string TagName => "div";
|
||||||
|
|
||||||
|
protected override IEnumerable<string> GetStyleClasses()
|
||||||
|
{
|
||||||
|
return new string[] { "uwt-actionpreviewbutton apb-show-text apb-style-ellipsis" };
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IList<Control> GetChildControls()
|
||||||
|
{
|
||||||
|
return base.GetChildControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
// <div data-ecid="56$279" data-instance-ids="22002$1" data-valid-class-ids="1$22002" data-autocomplete-url="~/prompt/c0/3$37643" class="mcx-instancebrowser mcx-editable mcx-editing">
|
||||||
|
// <div class="uwt-title">Manufacturer</div><input type="hidden" name="ec_56$276:56$279" value="22002$1"><input type="text" />
|
||||||
|
// <ul class="mcx-selected-items"><li>
|
||||||
|
// <div data-instance-id="22002$1" class="mcx-moniker uwt-actionpreviewbutton apb-show-text apb-style-ellipsis"><a class="apb-text" href="/super/d/inst/1$22002/22002$1.htmld">Paper Mate</a><a class="apb-button" href="/super/d/inst/22002$1/rel-tasks.htmld" tabindex="-1"> </a><div class="apb-preview uwt-popup"><div class="apb-actions uwt-empty"><h2>Available Actions</h2><ul class="uwt-menu"></ul></div><div class="apb-preview-content"><div class="apb-header"><h2><span class="apb-class-title">Manufacturer</span><a class="apb-text" href="/super/d/inst/1$22002/22002$1.htmld">Paper Mate</a></h2></div><div class="apb-content"></div></div><div class="uwt-spinner"> </div></div></div><a class="uwt-delete-button"></a></li></ul><div class="uwt-popup mcx-search-results uwt-loading mcx-placeholder-visible"><ul class="uwt-menu uwt-multiselect"></ul><div class="uwt-spinner"></div><div class="uwt-placeholder">type to search the list</div></div></div>
|
||||||
|
}
|
||||||
@ -2,14 +2,17 @@ namespace MBS.Web;
|
|||||||
|
|
||||||
public class WebContext
|
public class WebContext
|
||||||
{
|
{
|
||||||
public WebContext(WebApplication application, WebRequest request, WebResponse response)
|
public WebContext(WebApplication application, WebRequest request, WebResponse response, Dictionary<string, string> session)
|
||||||
{
|
{
|
||||||
Application = application;
|
Application = application;
|
||||||
Request = request;
|
Request = request;
|
||||||
Response = response;
|
Response = response;
|
||||||
|
Session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebApplication Application { get; }
|
public WebApplication Application { get; }
|
||||||
public WebRequest Request { get; }
|
public WebRequest Request { get; }
|
||||||
public WebResponse Response { get; }
|
public WebResponse Response { get; }
|
||||||
|
|
||||||
|
public Dictionary<string, string> Session { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,6 +133,8 @@ public class WebServer
|
|||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, Dictionary<string, string>> _sessions = new Dictionary<string, Dictionary<string, string>>();
|
||||||
|
|
||||||
private void HandleClient(System.Net.Sockets.TcpClient client)
|
private void HandleClient(System.Net.Sockets.TcpClient client)
|
||||||
{
|
{
|
||||||
// WebServerProcessRequestEventArgs e = new WebServerProcessRequestEventArgs();
|
// WebServerProcessRequestEventArgs e = new WebServerProcessRequestEventArgs();
|
||||||
@ -172,7 +174,6 @@ public class WebServer
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
string headerLine = sr.ReadLine();
|
string headerLine = sr.ReadLine();
|
||||||
Console.WriteLine(headerLine);
|
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(headerLine))
|
if (String.IsNullOrEmpty(headerLine))
|
||||||
break;
|
break;
|
||||||
@ -182,8 +183,6 @@ public class WebServer
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
headers[headerParts[0].Trim()] = headerParts[1].Trim();
|
headers[headerParts[0].Trim()] = headerParts[1].Trim();
|
||||||
|
|
||||||
Console.WriteLine("remaining: {0}", client.Available);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, string> form = new Dictionary<string, string>();
|
Dictionary<string, string> form = new Dictionary<string, string>();
|
||||||
@ -205,16 +204,45 @@ public class WebServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> session;
|
||||||
|
string cookie = "", cookieKey = "", cookieValue = "";
|
||||||
if (headers[HttpRequestHeader.Cookie] != null)
|
if (headers[HttpRequestHeader.Cookie] != null)
|
||||||
{
|
{
|
||||||
string cookie = headers[HttpRequestHeader.Cookie];
|
cookie = headers[HttpRequestHeader.Cookie];
|
||||||
|
|
||||||
|
string[] cookieParts = cookie.Split(new char[] { ';' });
|
||||||
|
if (cookieParts.Length >= 1)
|
||||||
|
{
|
||||||
|
string[] cookieParts2 = cookieParts[0].Split(new char[] { '=' });
|
||||||
|
if (cookieParts2.Length >= 2)
|
||||||
|
{
|
||||||
|
cookieKey = cookieParts2[0];
|
||||||
|
cookieValue = cookieParts2[1]; //cookies[cookieKey] = cookieValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_sessions.ContainsKey(cookieValue))
|
||||||
|
{
|
||||||
|
_sessions[cookieValue] = new Dictionary<string, string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
session = _sessions[cookieValue];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
session = new Dictionary<string, string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cookieValue == "")
|
||||||
|
{
|
||||||
|
cookieValue = "0068F5AD24A89AB4AFCC4057F619EADF.authgwy-prod-mzzygbiy.prod-ui-auth.pr502.cust.pdx.wd";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
Dictionary<string, string> pathVariables = new Dictionary<string, string>();
|
Dictionary<string, string> pathVariables = new Dictionary<string, string>();
|
||||||
|
|
||||||
WebContext context = new WebContext((WebApplication)Application.Instance, new WebRequest(version, requestMethod, path, headers, pathVariables, form), new WebResponse());
|
WebContext context = new WebContext((WebApplication)Application.Instance, new WebRequest(version, requestMethod, path, headers, pathVariables, form), new WebResponse(), session);
|
||||||
context.Response.Cookies.Add("JSESSIONID", "0068F5AD24A89AB4AFCC4057F619EADF.authgwy-prod-mzzygbiy.prod-ui-auth.pr502.cust.pdx.wd", WebCookieScope.FromPath("/"), WebCookieSecurity.Secure | WebCookieSecurity.HttpOnly, WebCookieSameSite.None);
|
context.Response.Cookies.Add("JSESSIONID", cookieValue, WebCookieScope.FromPath("/"), WebCookieSecurity.Secure | WebCookieSecurity.HttpOnly, WebCookieSameSite.None);
|
||||||
|
|
||||||
WebServerProcessRequestEventArgs e = new WebServerProcessRequestEventArgs(client, context);
|
WebServerProcessRequestEventArgs e = new WebServerProcessRequestEventArgs(client, context);
|
||||||
OnProcessRequest(e);
|
OnProcessRequest(e);
|
||||||
@ -234,11 +262,14 @@ public class WebServer
|
|||||||
// which... technically I guess it *should*, but... how do we get it to do what we WANT?
|
// which... technically I guess it *should*, but... how do we get it to do what we WANT?
|
||||||
|
|
||||||
if (route.Matches(path, pathVariables))
|
if (route.Matches(path, pathVariables))
|
||||||
|
{
|
||||||
|
lock (route.Handler)
|
||||||
{
|
{
|
||||||
route.Handler.ProcessRequest(context);
|
route.Handler.ProcessRequest(context);
|
||||||
|
|
||||||
WriteResponse(context, client.GetStream());
|
WriteResponse(context, client.GetStream());
|
||||||
found = true;
|
found = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user