public override void Execute(HttpContext context)
        {
            var writer = new HtmlTextWriter(context.Response.Output);

            context.Response.ContentType = "text/html";

            IHttpRequest  request  = new HttpRequestWrapper(ServicePath, GetType().Name, context.Request);
            IHttpResponse response = new HttpResponseWrapper(context.Response);

            HostContext.InitRequest(request, response);

            try
            {
                if (!EndpointHost.MetadataMap[request.ServicePath].MetadataFeatureEnabled)
                {
                    new NotFoundHttpHandler(request.ServicePath).ProcessRequest(request, response, request.OperationName);
                    return;
                }

                ProcessOperations(writer, request, response);
            }
            catch (Exception ex)
            {
                WriteException(writer, ex);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            IHttpRequest  request  = new HttpRequestWrapper(_servicePath, typeof(HystrixGlobalStreamHandler).Name, context.Request);
            IHttpResponse response = new HttpResponseWrapper(context.Response);

            HostContext.InitRequest(request, response);
            ProcessRequest(request, response, typeof(HystrixGlobalStreamHandler).Name);
        }
        public void ProcessRequest(HttpContext context)
        {
            IHttpRequest  request  = new EndpointsExtensions.HttpRequestWrapper(ServicePath, typeof(CustomOperationHandler).Name, context.Request);
            IHttpResponse response = new EndpointsExtensions.HttpResponseWrapper(context.Response);

            HostContext.InitRequest(request, response);
            ProcessRequest(request, response, typeof(CustomOperationHandler).Name);
        }
示例#4
0
        public void ProcessRequest(HttpContext context)
        {
            IHttpRequest  request  = new HttpRequestWrapper(_servicePath, typeof(RequestInfo).Name, context.Request);
            IHttpResponse response = new HttpResponseWrapper(context.Response);

            HostContext.InitRequest(request, response);
            ProcessRequest(request, response, typeof(RequestInfo).Name);
        }
示例#5
0
 private void Initialize()
 {
     _httpRequest  = new HttpRequestWrapper(ServicePath, OperationName, _context.Request);
     _httpResponse = new HttpResponseWrapper(_context.Response);
     HostContext.InitRequest(_httpRequest, _httpResponse);
     _executionResult = _httpResponse.ExecutionResult;
     _httpRequest.Items[InternalServiceUtils.SOA2CurrentOperationKey] = _operation.Key;
 }
示例#6
0
        public void ProcessRequest(HttpContext context)
        {
            var request  = context.Request;
            var response = context.Response;
            var httpReq  = new AntServiceStack.WebHost.Endpoints.Extensions.HttpRequestWrapper(_servicePath, typeof(SwaggerApiService).Name, request);
            var httpRes  = new AntServiceStack.WebHost.Endpoints.Extensions.HttpResponseWrapper(response);

            HostContext.InitRequest(httpReq, httpRes);
            ProcessRequest(httpReq, httpRes, null);
        }
示例#7
0
        public override void Execute(System.Web.HttpContext context)
        {
            IHttpRequest  request  = new HttpRequestWrapper(ServicePath, OperationName, context.Request);
            IHttpResponse response = new HttpResponseWrapper(context.Response);

            HostContext.InitRequest(request, response);

            if (!EndpointHost.MetadataMap[request.ServicePath].MetadataFeatureEnabled)
            {
                new NotFoundHttpHandler(request.ServicePath).ProcessRequest(request, response, request.OperationName);
                return;
            }
            ProcessRequest(request, response, OperationName);
        }
示例#8
0
        public void ProcessRequest(HttpContext context)
        {
            //if (_config.UseBasicAuth &&  context.Response.StatusCode == HttpNotAuthorizedStatusCode)
            //{
            //    context.Response.AddHeader(HttpWWWAuthenticateHeader, "Basic realm =\"" + Realm + "\"");
            //}

            var request  = context.Request;
            var response = context.Response;
            var httpReq  = new AntServiceStack.WebHost.Endpoints.Extensions.HttpRequestWrapper(_servicePath, typeof(SwaggerResourcesService).Name, request);
            var httpRes  = new AntServiceStack.WebHost.Endpoints.Extensions.HttpResponseWrapper(response);

            HostContext.InitRequest(httpReq, httpRes);
            ProcessRequest(httpReq, httpRes, null);
        }
示例#9
0
        public void ProcessRequest(HttpContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            var httpReq = new HttpRequestWrapper(_servicePath, "NotFoundHttpHandler", request);
            var httpRes = new HttpResponseWrapper(response);

            HostContext.InitRequest(httpReq, httpRes);
            if (!request.IsLocal)
            {
                ProcessRequest(httpReq, new HttpResponseWrapper(response), null);
                return;
            }

            Dictionary <string, string> logTags = new Dictionary <string, string>()
            {
                { "ErrorCode", "FXD300013" }
            };

            if (httpReq.UrlReferrer != null && !string.IsNullOrWhiteSpace(httpReq.UrlReferrer.AbsoluteUri))
            {
                logTags["Referer"] = httpReq.UrlReferrer.AbsoluteUri;
            }
            Log.Warn(string.Format("{0} Request not found: {1}", httpReq.RemoteIp, httpReq.RawUrl), logTags);

            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.ServicePath: " + _servicePath);
            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);
            sb.AppendLine("Request.Referer: " + (request.UrlReferrer == null ? string.Empty : request.UrlReferrer.AbsoluteUri));
            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 (!ApplicationBaseUrl.IsNullOrEmpty())
            {
                sb.AppendLine("App.ApplicationBaseUrl: " + ApplicationBaseUrl);
            }
            if (!AntServiceStackHttpHandlerFactory.DebugLastHandlerArgs.IsNullOrEmpty())
            {
                sb.AppendLine("App.DebugLastHandlerArgs: " + AntServiceStackHttpHandlerFactory.DebugLastHandlerArgs);
            }

            response.ContentType = "text/plain";
            response.StatusCode  = 404;
            response.EndHttpHandlerRequest(skipClose: true, afterBody: r => r.Write(sb.ToString()));
        }
示例#10
0
        protected override void ProcessRequest(HttpListenerContext context)
        {
            if (string.IsNullOrEmpty(context.Request.RawUrl))
            {
                return;
            }

            var operationName = context.Request.GetOperationName();

            var    httpReq = new HttpListenerRequestWrapper(operationName, context.Request);
            string pathInfo;
            string servicePath;

            AntServiceStackHttpHandlerFactory.GetServicePathInfo(httpReq.PathInfo, out servicePath, out pathInfo);
            httpReq.SetServicePath(servicePath);
            var httpRes = new HttpListenerResponseWrapper(context.Response);

            HostContext.InitRequest(httpReq, httpRes);

            var handler             = AntServiceStackHttpHandlerFactory.GetHandler(httpReq);
            var serviceStackHandler = handler as IServiceStackHttpHandler;

            if (serviceStackHandler != null)
            {
                var endpointHandler = serviceStackHandler as EndpointHandlerBase;
                if (endpointHandler != null)
                {
                    httpReq.OperationName = operationName = endpointHandler.RequestName;
                    if (!string.IsNullOrWhiteSpace(operationName))
                    {
                        bool isAsync = EndpointHost.MetadataMap[endpointHandler.ServicePath.ToLower()].OperationNameMap[operationName.ToLower()].IsAsync;
                        if (isAsync)
                        {
                            var task = endpointHandler.ProcessRequestAsync(httpReq, httpRes, operationName);
                            task.ContinueWith(t =>
                            {
                                try
                                {
                                    if (t.Exception != null)
                                    {
                                        log.Error("Error happened in async service execution!", t.Exception.InnerException ?? t.Exception,
                                                  new Dictionary <string, string>()
                                        {
                                            { "ErrorCode", "FXD300079" }, { "HostMode", "Self-Host" }
                                        });
                                    }
                                    httpRes.Close();
                                }
                                catch {  }
                            });
                            return;
                        }
                    }
                }

                serviceStackHandler.ProcessRequest(httpReq, httpRes, operationName);
                httpRes.Close();
                return;
            }

            throw new NotImplementedException("Cannot execute handler: " + handler + " at PathInfo: " + httpReq.PathInfo);
        }