public override Task ProcessRequestAsync(IRequest request, IResponse response, string operationName) { response.StatusCode = 403; response.ContentType = "text/plain"; return(response.EndHttpHandlerRequestAsync(skipClose: true, afterHeaders: r => { var sb = StringBuilderCache.Allocate() .Append($@"Forbidden Request.HttpMethod: {request.Verb} Request.PathInfo: {request.PathInfo} Request.QueryString: {request.QueryString} "); if (HostContext.Config.DebugMode) { sb.AppendLine($"Request.RawUrl: {request.RawUrl}"); if (IsIntegratedPipeline.HasValue) { sb.AppendLine($"App.IsIntegratedPipeline: {IsIntegratedPipeline}"); } if (!WebHostPhysicalPath.IsNullOrEmpty()) { sb.AppendLine($"App.WebHostPhysicalPath: {WebHostPhysicalPath}"); } if (!WebHostRootFileNames.IsEmpty()) { sb.AppendLine($"App.WebHostRootFileNames: {TypeSerializer.SerializeToString(WebHostRootFileNames)}"); } if (!WebHostUrl.IsNullOrEmpty()) { sb.AppendLine($"App.WebHostUrl: {WebHostUrl}"); } if (!DefaultRootFileName.IsNullOrEmpty()) { sb.AppendLine($"App.DefaultRootFileName: {DefaultRootFileName}"); } if (!DefaultHandler.IsNullOrEmpty()) { sb.AppendLine($"App.DefaultHandler: {DefaultHandler}"); } if (!HttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty()) { sb.AppendLine($"App.DebugLastHandlerArgs: {HttpHandlerFactory.DebugLastHandlerArgs}"); } } return response.OutputStream.WriteAsync(StringBuilderCache.ReturnAndFree(sb)); })); }
public override void ProcessRequest(IRequest request, IResponse response, string operationName) { response.ContentType = "text/plain"; response.StatusCode = 403; response.EndHttpHandlerRequest(skipClose: true, afterHeaders: r => { r.Write("Forbidden\n\n"); r.Write("\nRequest.HttpMethod: " + request.Verb); r.Write("\nRequest.PathInfo: " + request.PathInfo); r.Write("\nRequest.QueryString: " + request.QueryString); if (HostContext.Config.DebugMode) { r.Write("\nRequest.RawUrl: " + request.RawUrl); if (IsIntegratedPipeline.HasValue) { r.Write("\nApp.IsIntegratedPipeline: " + IsIntegratedPipeline); } if (!WebHostPhysicalPath.IsNullOrEmpty()) { r.Write("\nApp.WebHostPhysicalPath: " + WebHostPhysicalPath); } if (!WebHostRootFileNames.IsEmpty()) { r.Write("\nApp.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames)); } if (!WebHostUrl.IsNullOrEmpty()) { r.Write("\nApp.WebHostUrl: " + WebHostUrl); } if (!DefaultRootFileName.IsNullOrEmpty()) { r.Write("\nApp.DefaultRootFileName: " + DefaultRootFileName); } if (!DefaultHandler.IsNullOrEmpty()) { r.Write("\nApp.DefaultHandler: " + DefaultHandler); } if (!HttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty()) { r.Write("\nApp.DebugLastHandlerArgs: " + HttpHandlerFactory.DebugLastHandlerArgs); } } }); }
public void ProcessRequest(IHttpRequest request, IHttpResponse response, string operationName) { response.ContentType = "text/plain"; response.StatusCode = 403; response.Write("Forbidden\n\n"); response.Write("\nRequest.HttpMethod: " + request.HttpMethod); response.Write("\nRequest.PathInfo: " + request.PathInfo); response.Write("\nRequest.QueryString: " + request.QueryString); response.Write("\nRequest.RawUrl: " + request.RawUrl); if (IsIntegratedPipeline.HasValue) { response.Write("\nApp.IsIntegratedPipeline: " + IsIntegratedPipeline); } if (!WebHostPhysicalPath.IsNullOrEmpty()) { response.Write("\nApp.WebHostPhysicalPath: " + WebHostPhysicalPath); } if (!WebHostRootFileNames.IsEmpty()) { response.Write("\nApp.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames)); } if (!ApplicationBaseUrl.IsNullOrEmpty()) { response.Write("\nApp.ApplicationBaseUrl: " + ApplicationBaseUrl); } if (!DefaultRootFileName.IsNullOrEmpty()) { response.Write("\nApp.DefaultRootFileName: " + DefaultRootFileName); } if (!DefaultHandler.IsNullOrEmpty()) { response.Write("\nApp.DefaultHandler: " + DefaultHandler); } if (!ServiceStackHttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty()) { response.Write("\nApp.DebugLastHandlerArgs: " + ServiceStackHttpHandlerFactory.DebugLastHandlerArgs); } //Apache+mod_mono doesn't like this //response.OutputStream.Flush(); //response.Close(); }
public override void ProcessRequest(HttpContextBase context) { var request = context.Request; var response = context.Response; response.ContentType = "text/plain"; response.StatusCode = 403; context.EndHttpHandlerRequest(skipClose: true, afterHeaders: r => { r.Write("Forbidden\n\n"); r.Write("\nRequest.HttpMethod: " + request.HttpMethod); r.Write("\nRequest.PathInfo: " + request.PathInfo); r.Write("\nRequest.QueryString: " + request.QueryString); if (HostContext.Config.DebugMode) { r.Write("\nRequest.RawUrl: " + request.RawUrl); if (IsIntegratedPipeline.HasValue) { r.Write("\nApp.IsIntegratedPipeline: " + IsIntegratedPipeline); } if (!WebHostPhysicalPath.IsNullOrEmpty()) { r.Write("\nApp.WebHostPhysicalPath: " + WebHostPhysicalPath); } if (!WebHostRootFileNames.IsEmpty()) { r.Write("\nApp.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames)); } if (!WebHostUrl.IsNullOrEmpty()) { r.Write("\nApp.ApplicationBaseUrl: " + WebHostUrl); } if (!DefaultRootFileName.IsNullOrEmpty()) { r.Write("\nApp.DefaultRootFileName: " + DefaultRootFileName); } } }); }
protected StringBuilder CreateForbiddenResponseTextBody(IRequest request) { var sb = StringBuilderCache.Allocate() .Append($@"Forbidden Request.HttpMethod: {request.Verb} Request.PathInfo: {request.PathInfo} Request.QueryString: {request.QueryString} "); if (HostContext.Config.DebugMode) { sb.AppendLine($"Request.RawUrl: {request.RawUrl}"); if (!WebHostPhysicalPath.IsNullOrEmpty()) { sb.AppendLine($"App.WebHostPhysicalPath: {WebHostPhysicalPath}"); } if (!WebHostUrl.IsNullOrEmpty()) { sb.AppendLine($"App.WebHostUrl: {WebHostUrl}"); } if (!DefaultRootFileName.IsNullOrEmpty()) { sb.AppendLine($"App.DefaultRootFileName: {DefaultRootFileName}"); } if (!DefaultHandler.IsNullOrEmpty()) { sb.AppendLine($"App.DefaultHandler: {DefaultHandler}"); } if (!HttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty()) { sb.AppendLine($"App.DebugLastHandlerArgs: {HttpHandlerFactory.DebugLastHandlerArgs}"); } } return(sb); }
public void ProcessRequest(HttpContext context) { var request = context.Request; var response = context.Response; response.ContentType = "text/plain"; response.StatusCode = 403; response.Write("Forbidden\n\n"); response.Write("\nRequest.HttpMethod: " + request.HttpMethod); response.Write("\nRequest.PathInfo: " + request.PathInfo); response.Write("\nRequest.QueryString: " + request.QueryString); response.Write("\nRequest.RawUrl: " + request.RawUrl); if (IsIntegratedPipeline.HasValue) { response.Write("\nApp.IsIntegratedPipeline: " + IsIntegratedPipeline); } if (!WebHostPhysicalPath.IsNullOrEmpty()) { response.Write("\nApp.WebHostPhysicalPath: " + WebHostPhysicalPath); } if (!WebHostRootFileNames.IsEmpty()) { response.Write("\nApp.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames)); } if (!ApplicationBaseUrl.IsNullOrEmpty()) { response.Write("\nApp.ApplicationBaseUrl: " + ApplicationBaseUrl); } if (!DefaultRootFileName.IsNullOrEmpty()) { response.Write("\nApp.DefaultRootFileName: " + DefaultRootFileName); } //Apache+mod_mono doesn't like this //response.OutputStream.Flush(); //response.Close(); }
public void ProcessRequest(HttpContext context) { var request = context.Request; var response = context.Response; var httpReq = new HttpRequestWrapper("NotFoundHttpHandler", request); if (!request.IsLocal) { ProcessRequest(httpReq, new HttpResponseWrapper(response), null); return; } Log.ErrorFormat("{0} Request not found: {1}", request.UserHostAddress, request.RawUrl); var sb = new StringBuilder(); sb.AppendLine("Handler for Request not found: \n\n"); sb.AppendLine("Request.ApplicationPath: " + request.ApplicationPath); sb.AppendLine("Request.CurrentExecutionFilePath: " + request.CurrentExecutionFilePath); sb.AppendLine("Request.FilePath: " + request.FilePath); sb.AppendLine("Request.HttpMethod: " + request.HttpMethod); sb.AppendLine("Request.MapPath('~'): " + request.MapPath("~")); sb.AppendLine("Request.Path: " + request.Path); sb.AppendLine("Request.PathInfo: " + request.PathInfo); sb.AppendLine("Request.ResolvedPathInfo: " + httpReq.PathInfo); sb.AppendLine("Request.PhysicalPath: " + request.PhysicalPath); sb.AppendLine("Request.PhysicalApplicationPath: " + request.PhysicalApplicationPath); sb.AppendLine("Request.QueryString: " + request.QueryString); sb.AppendLine("Request.RawUrl: " + request.RawUrl); try { sb.AppendLine("Request.Url.AbsoluteUri: " + request.Url.AbsoluteUri); sb.AppendLine("Request.Url.AbsolutePath: " + request.Url.AbsolutePath); sb.AppendLine("Request.Url.Fragment: " + request.Url.Fragment); sb.AppendLine("Request.Url.Host: " + request.Url.Host); sb.AppendLine("Request.Url.LocalPath: " + request.Url.LocalPath); sb.AppendLine("Request.Url.Port: " + request.Url.Port); sb.AppendLine("Request.Url.Query: " + request.Url.Query); sb.AppendLine("Request.Url.Scheme: " + request.Url.Scheme); sb.AppendLine("Request.Url.Segments: " + request.Url.Segments); } catch (Exception ex) { sb.AppendLine("Request.Url ERROR: " + ex.Message); } if (IsIntegratedPipeline.HasValue) { sb.AppendLine("App.IsIntegratedPipeline: " + IsIntegratedPipeline); } if (!WebHostPhysicalPath.IsNullOrEmpty()) { sb.AppendLine("App.WebHostPhysicalPath: " + WebHostPhysicalPath); } if (!WebHostRootFileNames.IsEmpty()) { sb.AppendLine("App.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames)); } if (!ApplicationBaseUrl.IsNullOrEmpty()) { sb.AppendLine("App.ApplicationBaseUrl: " + ApplicationBaseUrl); } if (!DefaultRootFileName.IsNullOrEmpty()) { sb.AppendLine("App.DefaultRootFileName: " + DefaultRootFileName); } if (!DefaultHandler.IsNullOrEmpty()) { sb.AppendLine("App.DefaultHandler: " + DefaultHandler); } if (!ServiceStackHttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty()) { sb.AppendLine("App.DebugLastHandlerArgs: " + ServiceStackHttpHandlerFactory.DebugLastHandlerArgs); } response.ContentType = "text/plain"; response.StatusCode = 404; response.EndHttpHandlerRequest(skipClose: true, afterBody: r => r.Write(sb.ToString())); }
public override void ProcessRequest(HttpContextBase context) { var request = context.Request; var response = context.Response; var httpReq = context.ToRequest(GetType().GetOperationName()); if (!request.IsLocal) { ProcessRequestAsync(httpReq, httpReq.Response, null); return; } HostContext.AppHost.OnLogError(typeof(NotFoundHttpHandler), string.Format("{0} Request not found: {1}", request.UserHostAddress, request.RawUrl)); var sb = StringBuilderCache.Allocate(); sb.AppendLine("Handler for Request not found: \n\n"); sb.AppendLine("Request.ApplicationPath: " + request.ApplicationPath); sb.AppendLine("Request.CurrentExecutionFilePath: " + request.CurrentExecutionFilePath); sb.AppendLine("Request.FilePath: " + request.FilePath); sb.AppendLine("Request.HttpMethod: " + request.HttpMethod); sb.AppendLine("Request.MapPath('~'): " + request.MapPath("~")); sb.AppendLine("Request.Path: " + request.Path); sb.AppendLine("Request.PathInfo: " + request.PathInfo); sb.AppendLine("Request.ResolvedPathInfo: " + httpReq.PathInfo); sb.AppendLine("Request.PhysicalPath: " + request.PhysicalPath); sb.AppendLine("Request.PhysicalApplicationPath: " + request.PhysicalApplicationPath); sb.AppendLine("Request.QueryString: " + request.QueryString); sb.AppendLine("Request.RawUrl: " + request.RawUrl); try { sb.AppendLine("Request.Url.AbsoluteUri: " + request.Url.AbsoluteUri); sb.AppendLine("Request.Url.AbsolutePath: " + request.Url.AbsolutePath); sb.AppendLine("Request.Url.Fragment: " + request.Url.Fragment); sb.AppendLine("Request.Url.Host: " + request.Url.Host); sb.AppendLine("Request.Url.LocalPath: " + request.Url.LocalPath); sb.AppendLine("Request.Url.Port: " + request.Url.Port); sb.AppendLine("Request.Url.Query: " + request.Url.Query); sb.AppendLine("Request.Url.Scheme: " + request.Url.Scheme); sb.AppendLine("Request.Url.Segments: " + request.Url.Segments); } catch (Exception ex) { sb.AppendLine("Request.Url ERROR: " + ex.Message); } if (IsIntegratedPipeline.HasValue) { sb.AppendLine("App.IsIntegratedPipeline: " + IsIntegratedPipeline); } if (!WebHostPhysicalPath.IsNullOrEmpty()) { sb.AppendLine("App.WebHostPhysicalPath: " + WebHostPhysicalPath); } if (!WebHostRootFileNames.IsEmpty()) { sb.AppendLine("App.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames)); } if (!WebHostUrl.IsNullOrEmpty()) { sb.AppendLine("App.ApplicationBaseUrl: " + WebHostUrl); } if (!DefaultRootFileName.IsNullOrEmpty()) { sb.AppendLine("App.DefaultRootFileName: " + DefaultRootFileName); } if (!DefaultHandler.IsNullOrEmpty()) { sb.AppendLine("App.DefaultHandler: " + DefaultHandler); } if (!HttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty()) { sb.AppendLine("App.DebugLastHandlerArgs: " + HttpHandlerFactory.DebugLastHandlerArgs); } response.ContentType = "text/plain"; response.StatusCode = 404; var text = StringBuilderCache.ReturnAndFree(sb); context.EndHttpHandlerRequest(skipClose: true, afterHeaders: r => r.Write(text)); }
public void ProcessRequest(HttpContext context) { var request = context.Request; var response = context.Response; var httpReq = new HttpRequestWrapper("NotFoundHttpHandler", request); response.ContentType = "text/plain"; response.StatusCode = 404; response.Write("Handler for Request not found: \n\n"); response.Write("\nRequest.ApplicationPath: " + request.ApplicationPath); response.Write("\nRequest.CurrentExecutionFilePath: " + request.CurrentExecutionFilePath); response.Write("\nRequest.FilePath: " + request.FilePath); response.Write("\nRequest.HttpMethod: " + request.HttpMethod); response.Write("\nRequest.MapPath('~'): " + request.MapPath("~")); response.Write("\nRequest.Path: " + request.Path); response.Write("\nRequest.PathInfo: " + request.PathInfo); response.Write("\nRequest.ResolvedPathInfo: " + httpReq.PathInfo); response.Write("\nRequest.PhysicalPath: " + request.PhysicalPath); response.Write("\nRequest.PhysicalApplicationPath: " + request.PhysicalApplicationPath); response.Write("\nRequest.QueryString: " + request.QueryString); response.Write("\nRequest.RawUrl: " + request.RawUrl); try { response.Write("\nRequest.Url.AbsoluteUri: " + request.Url.AbsoluteUri); response.Write("\nRequest.Url.AbsolutePath: " + request.Url.AbsolutePath); response.Write("\nRequest.Url.Fragment: " + request.Url.Fragment); response.Write("\nRequest.Url.Host: " + request.Url.Host); response.Write("\nRequest.Url.LocalPath: " + request.Url.LocalPath); response.Write("\nRequest.Url.Port: " + request.Url.Port); response.Write("\nRequest.Url.Query: " + request.Url.Query); response.Write("\nRequest.Url.Scheme: " + request.Url.Scheme); response.Write("\nRequest.Url.Segments: " + request.Url.Segments); } catch (Exception ex) { response.Write("\nRequest.Url ERROR: " + ex.Message); } if (IsIntegratedPipeline.HasValue) { response.Write("\nApp.IsIntegratedPipeline: " + IsIntegratedPipeline); } if (!WebHostPhysicalPath.IsNullOrEmpty()) { response.Write("\nApp.WebHostPhysicalPath: " + WebHostPhysicalPath); } if (!WebHostRootFileNames.IsEmpty()) { response.Write("\nApp.WebHostRootFileNames: " + TypeSerializer.SerializeToString(WebHostRootFileNames)); } if (!ApplicationBaseUrl.IsNullOrEmpty()) { response.Write("\nApp.ApplicationBaseUrl: " + ApplicationBaseUrl); } if (!DefaultRootFileName.IsNullOrEmpty()) { response.Write("\nApp.DefaultRootFileName: " + DefaultRootFileName); } if (!DefaultHandler.IsNullOrEmpty()) { response.Write("\nApp.DefaultHandler: " + DefaultHandler); } if (!ServiceStackHttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty()) { response.Write("\nApp.DebugLastHandlerArgs: " + ServiceStackHttpHandlerFactory.DebugLastHandlerArgs); } //Apache+mod_mono doesn't like this //response.OutputStream.Flush(); //response.Close(); }