protected override void OnRequestReceived(RequestEventArgs <HttpRequest, HttpResponse> rea) { base.OnRequestReceived(rea); if (HttpRequestReceived != null) { HttpRequestReceived(this, (HttpServerEventArgs)rea); } }
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); } }
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); } }
public abstract void Execute(RequestEventArgs e);
static void server_RequestReceived(object sender, RequestEventArgs<HttpRequest, HttpResponse> e) { Console.WriteLine("Request received from " + e.Host); }
public void OnRequestReceived(RequestEventArgs rea) { if (RequestReceived != null) RequestReceived(this, rea); }