internal HttpListenerContext(HttpConnection connection)
 {
     _connection = connection;
       _errorStatus = 400;
       _request = new HttpListenerRequest (this);
       _response = new HttpListenerResponse (this);
 }
        private void cleanupConnections()
        {
            lock (_connectionsSync) {
            if (_connections.Count == 0)
              return;

            // Need to copy this since closing will call the RemoveConnection method.
            var keys = _connections.Keys;
            var conns = new HttpConnection[keys.Count];
            keys.CopyTo (conns, 0);
            _connections.Clear ();
            for (var i = conns.Length - 1; i >= 0; i--)
              conns[i].Close (true);
              }
        }
 internal void RemoveConnection(HttpConnection connection)
 {
     lock (_connectionsSync)
     _connections.Remove (connection);
 }
 internal void AddConnection(HttpConnection connection)
 {
     lock (_connectionsSync)
     _connections[connection] = connection;
 }