private void ConnectedCallback(IAsyncResult r) { HTTPConnection conn; try { conn = new HTTPConnection(s.EndAccept(r)); Core.EntryPoint.SubscribeConnection(conn); } catch (ObjectDisposedException) { return; } connections.Add(conn); AcceptConnection(); }
private void AllowConn(Socket sckt) { var conn = new HTTPConnection(sckt); connections.Add(conn); EntryPoint.SubscribeConnection(conn); }
// static so that each HTTPConnection doesn't need a reference internal static void RemoveConnection(HTTPConnection c) { remove(c); }
private void RemoveConnection_(HTTPConnection c) { connections.Remove(c); if (connsPerIP[c.RemoteIP] == 1) { connsPerIP.Remove(c.RemoteIP); } else { connsPerIP[c.RemoteIP] = (byte) (connsPerIP[c.RemoteIP] - 1); } }
internal static void AddTimeout(HTTPConnection conn) { timeouts.TryAdd(GetMS() + 2000, conn); }
internal static void SubscribeConnection(HTTPConnection c) { c.RequestReceived += OnRequest; }
private static void OnRequest(Request r, HTTPConnection.RequestCompleteHandler callback) { IPage p; if (! pages.TryGetValue(r.URI, out p)) { p = specials[HTTPCode.NotFound]; callback(p.Get(r)); } var res = p.Get(r); if (res.Keep_Alive == null) { res.Keep_Alive = r.Keep_Alive; // Unless the page specifically accepted or denied keeping the connection open, go with what the client asked. } foreach (var c in res.cookies) { if (c.Path == null) { c.Path = p.GetPath(); // Set the cookie's path if it wasn't specified. } CookieManager.AddCookie(c); } callback(res); }
private static void OnRequest(Request r, HTTPConnection.RequestCompleteHandler callback) { Page p; if (! pages.TryGetValue(r.URI, out p)) { p = specials[HTTPCode.NotFound]; } callback(p.Get(r)); }