コード例 #1
0
 public void FilterRequest(RequestContext request, ResponseContext response)
 {
     if (request.Uri.LocalPath == "\\DontLetMeIn")
     {
         response.HttpStatusCode = new Forbidden();
         response.Data = "Forbidden - 403";
     }
 }
コード例 #2
0
        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;
        }
コード例 #3
0
        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();
        }
コード例 #4
0
 public HttpContext(RequestContext requestContext, ResponseContext responseContext, Socket socket)
 {
     Request = requestContext;
     Response = responseContext;
     Socket = socket;
 }
コード例 #5
0
 private void SetContentLength(ResponseContext response)
 {
     response.Headers["Content-Length"] = response.DataLength;
     response.Headers["ContentType"] = response.ContentType.ToString();
 }
コード例 #6
0
 private void SetContentLength(ResponseContext response)
 {
     response.Headers["Content-Length"] = response.DataLength;
     response.Headers["ContentType"]    = response.ContentType.ToString();
 }
コード例 #7
0
ファイル: HttpContext.cs プロジェクト: lamebrain/WebServer
 public HttpContext(RequestContext requestContext, ResponseContext responseContext, Socket socket)
 {
     Request  = requestContext;
     Response = responseContext;
     Socket   = socket;
 }