Exemplo n.º 1
0
        private static IHttpHandler ReturnRequestInfo(IHttpRequest httpReq)
        {
            if (EndpointHost.Config.DebugOnlyReturnRequestInfo)
            {
                var reqInfo = RequestInfoHandler.GetRequestInfo(httpReq);

                reqInfo.Host     = EndpointHost.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + EndpointHost.Config.ServiceName;
                reqInfo.PathInfo = httpReq.PathInfo;
                reqInfo.Path     = httpReq.GetPathUrl();

                return(new RequestInfoHandler {
                    RequestInfo = reqInfo
                });
            }

            return(null);
        }
Exemplo n.º 2
0
        internal static IHttpHandler ReturnRequestInfo(IHttpRequest httpReq)
        {
            if (HostContext.Config.DebugOnlyReturnRequestInfo ||
                (HostContext.DebugMode && httpReq.PathInfo.EndsWith("__requestinfo")))
            {
                var reqInfo = RequestInfoHandler.GetRequestInfo(httpReq);

                reqInfo.Host     = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName;
                reqInfo.PathInfo = httpReq.PathInfo;
                reqInfo.Path     = httpReq.GetPathUrl();

                return(new RequestInfoHandler {
                    RequestInfo = reqInfo
                });
            }

            return(null);
        }
Exemplo n.º 3
0
        private static IHttpHandler ReturnRequestInfo(IHttpRequest httpReq)
        {
            if (EndpointHost.Config.DebugOnlyReturnRequestInfo ||
                (EndpointHost.DebugMode && httpReq.PathInfo.EndsWith("__requestinfo")))
            {
                var reqInfo = RequestInfoHandler.GetRequestInfo(httpReq);

                reqInfo.Host     = EndpointHost.Config.DebugHttpListenerHostEnvironment + "_v" + Env.AntServiceStackVersion + "_" + EndpointHost.Config.MetadataMap[httpReq.ServicePath].FullServiceName;
                reqInfo.PathInfo = httpReq.PathInfo;
                reqInfo.Path     = httpReq.GetPathUrl();

                return(new RequestInfoHandler(httpReq.ServicePath)
                {
                    RequestInfo = reqInfo
                });
            }

            return(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// If enabled, just returns the Request Info as it understands
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private static IHttpHandler ReturnRequestInfo(HttpRequest request)
        {
            if (EndpointHost.Config.DebugOnlyReturnRequestInfo)
            {
                var reqInfo = RequestInfoHandler.GetRequestInfo(
                    new HttpRequestWrapper(typeof(RequestInfo).Name, request));

                reqInfo.Host = EndpointHost.Config.DebugAspNetHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + EndpointHost.Config.ServiceName;
                //reqInfo.FactoryUrl = url; //Just RawUrl without QueryString
                //reqInfo.FactoryPathTranslated = pathTranslated; //Local path on filesystem
                reqInfo.PathInfo        = request.PathInfo;
                reqInfo.Path            = request.Path;
                reqInfo.ApplicationPath = request.ApplicationPath;

                return(new RequestInfoHandler {
                    RequestInfo = reqInfo
                });
            }

            return(null);
        }
Exemplo n.º 5
0
        internal static IHttpHandler ReturnRequestInfo(IHttpRequest httpReq)
        {
            if ((HostContext.DebugMode ||
                 HostContext.Config.AdminAuthSecret != null) &&
                httpReq.QueryString["debug"] == RequestInfoHandler.RestPath)
            {
                if (HostContext.DebugMode || HostContext.HasValidAuthSecret(httpReq))
                {
                    var reqInfo = RequestInfoHandler.GetRequestInfo(httpReq);

                    reqInfo.Host       = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName;
                    reqInfo.PathInfo   = httpReq.PathInfo;
                    reqInfo.GetPathUrl = httpReq.GetPathUrl();

                    return(new RequestInfoHandler {
                        RequestInfo = reqInfo
                    });
                }
            }

            return(null);
        }
 public RequestInfoResponse Any(RequestInfo request)
 {
     return(RequestInfoHandler.GetRequestInfo(base.Request));
 }
            public RequestInfoResponse Any(RequestInfo request)
            {
                var requestInfo = RequestInfoHandler.GetRequestInfo(base.Request);

                return(requestInfo);
            }
Exemplo n.º 8
0
        internal static void LogError(string title, IHttpRequest httpRequest, ResponseStatusType responseStatus, string errorCode, LogLevel logLevel)
        {
            if (httpRequest == null)
            {
                return;
            }

            ServiceMetadata             metadata = EndpointHost.Config.MetadataMap[httpRequest.ServicePath];
            Dictionary <string, string> additionalExceptionInfo = new Dictionary <string, string>()
            {
                { "Version", ServiceUtils.SOA2VersionCatName },
                { "Operation", metadata.FullServiceName + "." + httpRequest.OperationName }
            };

            string clientAppId = httpRequest.GetClientAppId();

            if (!string.IsNullOrWhiteSpace(clientAppId))
            {
                additionalExceptionInfo.Add("ClientAppId", clientAppId);
            }

            if (!string.IsNullOrWhiteSpace(errorCode))
            {
                additionalExceptionInfo.Add("ErrorCode", errorCode);
            }

            if (metadata.LogErrorWithRequestInfo)
            {
                try
                {
                    try
                    {
                        var requestInfo = RequestInfoHandler.GetRequestInfo(httpRequest);
                        additionalExceptionInfo["RequestInfo"] = TypeSerializer.SerializeToString(requestInfo);
                    }
                    catch
                    {
                        Dictionary <string, string> requestInfo = new Dictionary <string, string>()
                        {
                            { "Url", httpRequest.RawUrl },
                            { "PathInfo", httpRequest.PathInfo },
                            { "QueryString", TypeSerializer.SerializeToString(httpRequest.QueryString) },
                            { "Headers", TypeSerializer.SerializeToString(httpRequest.Headers) },
                            { "FormData", TypeSerializer.SerializeToString(httpRequest.FormData) }
                        };
                        additionalExceptionInfo["RequestInfo"] = TypeSerializer.SerializeToString(requestInfo);
                    }
                }
                catch
                {
                }

                if (httpRequest.RequestObject != null && !(httpRequest.RequestObject is RequestInfoResponse))
                {
                    additionalExceptionInfo["RequestObject"] = TypeSerializer.SerializeToString(httpRequest.RequestObject);
                }
            }

            string message = string.Empty;

            if (responseStatus != null)
            {
                additionalExceptionInfo["ResponseStatus"] = TypeSerializer.SerializeToString(responseStatus);
                if (responseStatus.Errors != null && responseStatus.Errors.Count > 0 && responseStatus.Errors[0] != null)
                {
                    message = string.Format("ErrorCode: {0}, Message: {1}", responseStatus.Errors[0].ErrorCode, responseStatus.Errors[0].Message);
                }
            }

            switch (logLevel)
            {
            case LogLevel.DEBUG:
                Log.Debug(title, message, additionalExceptionInfo);
                break;

            case LogLevel.INFO:
                Log.Info(title, message, additionalExceptionInfo);
                break;

            case LogLevel.WARN:
                Log.Warn(title, message, additionalExceptionInfo);
                break;

            case LogLevel.ERROR:
                Log.Error(title, message, additionalExceptionInfo);
                break;

            case LogLevel.FATAL:
                Log.Fatal(title, message, additionalExceptionInfo);
                break;
            }
        }
Exemplo n.º 9
0
        internal static void LogError(string title, IHttpRequest httpRequest, Exception ex, string errorCode, LogLevel logLevel)
        {
            if (httpRequest == null)
            {
                return;
            }

            ServiceMetadata             metadata = EndpointHost.Config.MetadataMap[httpRequest.ServicePath];
            Dictionary <string, string> additionalExceptionInfo = new Dictionary <string, string>()
            {
                { "Operation", metadata.FullServiceName + "." + httpRequest.OperationName }
            };

            string clientAppId = httpRequest.GetClientAppId();

            if (!string.IsNullOrWhiteSpace(clientAppId))
            {
                additionalExceptionInfo.Add("ClientAppId", clientAppId);
            }

            if (!string.IsNullOrWhiteSpace(errorCode))
            {
                additionalExceptionInfo.Add("ErrorCode", errorCode);
            }

            if (metadata.LogErrorWithRequestInfo)
            {
                try
                {
                    try
                    {
                        var requestInfo = RequestInfoHandler.GetRequestInfo(httpRequest);
                        additionalExceptionInfo["RequestInfo"] = TypeSerializer.SerializeToString(requestInfo);
                    }
                    catch
                    {
                        Dictionary <string, string> requestInfo = new Dictionary <string, string>()
                        {
                            { "Url", httpRequest.RawUrl },
                            { "PathInfo", httpRequest.PathInfo },
                            { "QueryString", TypeSerializer.SerializeToString(httpRequest.QueryString) },
                            { "Headers", TypeSerializer.SerializeToString(httpRequest.Headers) },
                            { "FormData", TypeSerializer.SerializeToString(httpRequest.FormData) }
                        };
                        additionalExceptionInfo["RequestInfo"] = TypeSerializer.SerializeToString(requestInfo);
                    }
                }
                catch
                {
                }

                if (httpRequest.RequestObject != null && !(httpRequest.RequestObject is RequestInfoResponse))
                {
                    additionalExceptionInfo["RequestObject"] = TypeSerializer.SerializeToString(httpRequest.RequestObject);
                }
            }

            switch (logLevel)
            {
            case LogLevel.DEBUG:
                if (ex != null)
                {
                    Log.Error(title, ex, additionalExceptionInfo);
                }
                else
                {
                    Log.Error(title, string.Empty, additionalExceptionInfo);
                }
                break;

            case LogLevel.INFO:
                if (ex != null)
                {
                    Log.Info(title, ex, additionalExceptionInfo);
                }
                else
                {
                    Log.Info(title, string.Empty, additionalExceptionInfo);
                }
                break;

            case LogLevel.WARN:
                if (ex != null)
                {
                    Log.Warn(title, ex, additionalExceptionInfo);
                }
                else
                {
                    Log.Warn(title, string.Empty, additionalExceptionInfo);
                }
                break;

            case LogLevel.ERROR:
                if (ex != null)
                {
                    Log.Error(title, ex, additionalExceptionInfo);
                }
                else
                {
                    Log.Error(title, string.Empty, additionalExceptionInfo);
                }
                break;

            case LogLevel.FATAL:
                if (ex != null)
                {
                    Log.Fatal(title, ex, additionalExceptionInfo);
                }
                else
                {
                    Log.Fatal(title, string.Empty, additionalExceptionInfo);
                }
                break;
            }
        }