Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 private void AllowConn(Socket sckt)
 {
     var conn = new HTTPConnection(sckt);
     connections.Add(conn);
     EntryPoint.SubscribeConnection(conn);
 }
Ejemplo n.º 3
0
 // static so that each HTTPConnection doesn't need a reference
 internal static void RemoveConnection(HTTPConnection c)
 {
     remove(c);
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
 internal static void AddTimeout(HTTPConnection conn)
 {
     timeouts.TryAdd(GetMS() + 2000, conn);
 }
Ejemplo n.º 6
0
 internal static void SubscribeConnection(HTTPConnection c)
 {
     c.RequestReceived += OnRequest;
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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));
        }