Наследование: Logging, IRequest, IDisposable
Пример #1
0
 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;
 }
Пример #2
0
 internal void RemoveClient(HttpClient client)
 {
   DateTime ignored;
   clients.TryRemove(client, out ignored);
 }
Пример #3
0
 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;
       });
       DebugFormat("Accepted client {0}", client);
       client.Start();
     }
     catch (Exception) {
       client.Dispose();
       throw;
     }
   }
   catch (ObjectDisposedException) {
   }
   catch (Exception ex) {
     Error("Failed to accept a client", ex);
   }
   finally {
     Accept();
   }
 }