예제 #1
0
        public void Process(IHandler handler)
        {
            if (handler == null) throw new ArgumentException();

            Response response;
            try
            {
                response = handler.Process(this._request);
                response.Status = Constants.STATUS_CODE_200;
                response.ReasonPhrase = "OK";
            }
            catch (ResourceNotFoundException reNtFdEx)
            {
                ExceptionPolicy.HandleException(reNtFdEx);

                response = new Response(this._request.Socket);
                response.Status = Constants.STATUS_CODE_404;
                response.ReasonPhrase = "Not Found";
            } 
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex);

                response = new Response(this._request.Socket);
                response.Status = Constants.STATUS_CODE_500;
                response.ReasonPhrase = "Internal Server Error";
            }

            response.Send();
        }
예제 #2
0
 private void SendEmptyResponse(Request request)
 {
     var response = new Response(request.Socket);
     response.Status = Constants.STATUS_CODE_204;
     response.ReasonPhrase = "No Content";
     response.Send();
 }
예제 #3
0
 private void SendInternalServerResponse(Request request)
 {
     var response = new Response(request.Socket);
     response.Status = Constants.STATUS_CODE_500;
     response.ReasonPhrase = "Internal Server Error";
     response.Send();
 }