HttpServer.Server.OnBeforeRequest C# (CSharp) Method

OnBeforeRequest() protected method

A request have arrived but not yet been processed yet.
Default implementation adds a Date header and Server header.
protected OnBeforeRequest ( HttpServer.RequestContext context ) : void
context HttpServer.RequestContext The context.
return void
        protected virtual void OnBeforeRequest(RequestContext context)
        {
            if (context.Request.ContentLength.Value > MaxContentSize)
                throw new HttpException(HttpStatusCode.RequestEntityTooLarge, "Too large body, limit is " + MaxContentSize);

            context.Response.Add(new DateHeader("Date", DateTime.UtcNow));
            context.Response.Add(new StringHeader("Server", ServerName));
        }