internal void RemoveClient(HttpClient client) { DateTime ignored; clients.TryRemove(client, out ignored); }
private void AcceptCallback(IAsyncResult result) { try { var tcpclient = listener.EndAcceptTcpClient(result); var client = new HttpClient(this, tcpclient); try { clients.AddOrUpdate(client, DateTime.Now, (k, v) => { return DateTime.Now; }); Logger.DebugFormat("Accepted client {0}", client); client.Start(); } catch (Exception) { client.Dispose(); throw; } } catch (ObjectDisposedException) { } catch (Exception ex) { Logger.Error("Failed to accept a client", ex); } finally { Accept(); } }
internal bool AuthorizeClient(HttpClient client) { if (OnAuthorizeClient == null) { return true; } if (IPAddress.IsLoopback(client.RemoteEndpoint.Address)) { return true; } var e = new HttpAuthorizationEventArgs( client.Headers, client.RemoteEndpoint); OnAuthorizeClient(this, e); return !e.Cancel; }