Example #1
0
 public void FilterRequest(RequestContext request, ResponseContext response)
 {
     if (request.Uri.LocalPath == "\\DontLetMeIn")
     {
         response.HttpStatusCode = new Forbidden();
         response.Data = "Forbidden - 403";
     }
 }
        internal void BuildResponseContextBase(ResponseContext responseContext, RequestContext requestContext)
        {
            responseContext.Headers.AddValue("ContentType", ""); // Content-Type: text/html; charset=utf-8
            responseContext.Headers.AddValue("Content-Length", "0");
            responseContext.Headers.AddValue("Accept-Ranges", "bytes");
            responseContext.Headers.AddValue("Connection", "close");
            responseContext.Headers.AddValue("Server", "Fredde Web Server 1.0");

            responseContext.HttpVersion = "HTTP/1.1";
            return;
        }
        public string BuildResponseLineAndHeaders(ResponseContext responseContext)
        {
            SetContentLength(responseContext);

            var responseLineAndHeaders = new StringBuilder(responseContext.HttpVersion + " " + responseContext.HttpStatusCode.StatusCode + " " + responseContext.HttpStatusCode.ReasonPhrase + "\r\n");
            foreach (var key in responseContext.Headers.Keys)
            {
                var value = responseContext.Headers[key.ToString()];
                responseLineAndHeaders.Append(key + ": " + value + "\r\n");
            }
            responseLineAndHeaders.Append("\r\n");

            return responseLineAndHeaders.ToString();
        }
 public HttpContext(RequestContext requestContext, ResponseContext responseContext, Socket socket)
 {
     Request = requestContext;
     Response = responseContext;
     Socket = socket;
 }
 private void SetContentLength(ResponseContext response)
 {
     response.Headers["Content-Length"] = response.DataLength;
     response.Headers["ContentType"] = response.ContentType.ToString();
 }
 private void SetContentLength(ResponseContext response)
 {
     response.Headers["Content-Length"] = response.DataLength;
     response.Headers["ContentType"]    = response.ContentType.ToString();
 }
Example #7
0
 public HttpContext(RequestContext requestContext, ResponseContext responseContext, Socket socket)
 {
     Request  = requestContext;
     Response = responseContext;
     Socket   = socket;
 }