Inheritance: 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);