コード例 #1
0
 public override void BeforeHeaders(HttpResponse response)
 {
     if (IsPartial)
         response.StatusCode = HttpStatusCode.PartialContent;
 }
コード例 #2
0
 /// <summary>
 /// Hook for modifying the http response before headers are sent.
 /// </summary>
 /// <param name="response"></param>
 public virtual void BeforeHeaders(HttpResponse response)
 {
 }
コード例 #3
0
        void Close()
        {
            if (Closed)
                return;

            asyncArgs.Dispose();
            response.Producer.Disconnect();
            response.Producer.Dispose();
            response = null;
            request = null;
            socket.Close();
            Closed = true;
        }
コード例 #4
0
 /// <summary>
 /// Start writing the HTTP response.
 /// </summary>
 /// <param name="response"></param>
 public void AsyncWrite(HttpRequest request, HttpResponse response)
 {
     this.request = request;
     this.response = response;
     SendHeaders();
 }
コード例 #5
0
ファイル: HttpServer.cs プロジェクト: MagistrAVSH/manicdigger
 /// <summary>
 /// Async event handles HTTP requests received.
 /// </summary>
 /// <param name="request"></param>
 void ProcessRequest(HttpRequest request)
 {
     var handledByModule = false;
     lock (_modules)
     {
         foreach (var module in _modules)
         {
             if (module.ResponsibleForRequest(request))
             {
                 handledByModule = true;
                 var args = new ProcessRequestEventArgs();
                 args.Request = request;
                 args.Response = new HttpResponse()
                 {
                     HttpVersion = request.Version,
                     StatusCode = HttpStatusCode.OK,
                     Connection = HttpConnection.Close,
                     Headers = new Dictionary<string,string>()
                 };
                 args.Completed += ModuleProcessComplete;
                 if (!module.ProcessAsync(args))
                     ModuleProcessComplete(module, args);
             }
         }
     }
     if (!handledByModule)
     {
         var response = new HttpResponse();
         response.StatusCode = HttpStatusCode.NotFound;
         response.Headers.Add("Content-Type", "text/plain");
         response.Producer = new BufferedProducer("404 - Not Found");
         var writer = new HttpResponseWriter(request.ClientSocket);
         writer.AsyncWrite(request, response);
     }
 }
コード例 #6
0
ファイル: HttpServer.cs プロジェクト: MagistrAVSH/manicdigger
 void ProcessHttpError(HttpStatusCode httpStatusCode, HttpRequest request)
 {
     var response = new HttpResponse();
     response.StatusCode = httpStatusCode;
     response.Producer = new BufferedProducer("An error occurred, please hang tight");
     var writer = new HttpResponseWriter(request.ClientSocket);
     writer.AsyncWrite(request, response);
 }