Наследование: System.EventArgs
Пример #1
0
 protected override void OnRequestReceived(RequestEventArgs <HttpRequest, HttpResponse> rea)
 {
     base.OnRequestReceived(rea);
     if (HttpRequestReceived != null)
     {
         HttpRequestReceived(this, (HttpServerEventArgs)rea);
     }
 }
Пример #2
0
 protected override void Treat(RequestEventArgs <HttpRequest, HttpResponse> rea, Stream client)
 {
     try
     {
         base.Treat(rea, client);
         if (rea.Response.Headers.ContainsKey("Connection") && rea.Response.Headers["Connection"] == "Keep-Alive")
         {
             Treat(GetEventArgs(rea.Request), client);
         }
     }
     catch (NotImplementedException e)
     {
         ReplyError(client, e, HttpStatusCode.NotImplemented);
     }
     catch (Exception e)
     {
         ReplyError(client, e, HttpStatusCode.BadRequest);
     }
 }
Пример #3
0
 private void ReceiveRequest(IAsyncResult result)
 {
     RequestEventArgs rea = new RequestEventArgs();
     IPEndPoint ep = new IPEndPoint(IPAddress.Any, Port);
     byte[] requestBytes = client.EndReceive(result, ref ep);
     if (IsStarted)
         client.BeginReceive(ReceiveRequest, null);
     HttpRequest request = HttpRequest.FromBytes(requestBytes);
     rea.Request = request;
     rea.Host = ep;
     try
     {
         OnRequestReceived(rea);
         Reply(ep, rea.Response);
     }
     catch (NotImplementedException e)
     {
         ReplyError(ep, e, HttpStatusCode.NotImplemented);
     }
     catch (Exception e)
     {
         ReplyError(ep, e, HttpStatusCode.BadRequest);
     }
 }
Пример #4
0
 public abstract void Execute(RequestEventArgs e);
Пример #5
0
 static void server_RequestReceived(object sender, RequestEventArgs<HttpRequest, HttpResponse> e)
 {
     Console.WriteLine("Request received from " + e.Host);
 }
Пример #6
0
 public void OnRequestReceived(RequestEventArgs rea)
 {
     if (RequestReceived != null)
         RequestReceived(this, rea);
 }
Пример #7
0
 public abstract void Execute(RequestEventArgs e);