public static RequestInfoResponse GetRequestInfo(IRequest httpReq)
        {
            int virtualPathCount = 0;

            int.TryParse(httpReq.QueryString["virtualPathCount"], out virtualPathCount);
            var hostType = HostContext.AppHost.GetType();

            var response = new RequestInfoResponse
            {
                Usage                       = "append '?debug=requestinfo' to any querystring. Optional params: virtualPathCount",
                Host                        = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName,
                HostType                    = "{0} ({1})".Fmt(HostContext.IsAspNetHost ? "ASP.NET" : "SelfHost", hostType.BaseType != null ? hostType.BaseType.Name : hostType.Name),
                Date                        = DateTime.UtcNow.ToString("yy-MM-dd HH:mm:ss"),
                ServiceName                 = HostContext.ServiceName,
                HandlerFactoryPath          = HostContext.Config.HandlerFactoryPath,
                UserHostAddress             = httpReq.UserHostAddress,
                HttpMethod                  = httpReq.Verb,
                AbsoluteUri                 = httpReq.AbsoluteUri,
                WebHostUrl                  = HostContext.Config.WebHostUrl,
                ApplicationBaseUrl          = httpReq.GetBaseUrl(),
                ResolveAbsoluteUrl          = HostContext.AppHost.ResolveAbsoluteUrl("~/resolve", httpReq),
                RootDirectoryPath           = HostContext.VirtualFileSources.RootDirectory.RealPath,
                StripApplicationVirtualPath = HostContext.Config.StripApplicationVirtualPath,
                CurrentDirectory            = Directory.GetCurrentDirectory(),
                RawUrl                      = httpReq.RawUrl,
                ResolvedPathInfo            = httpReq.PathInfo,
                ContentType                 = httpReq.ContentType,
                Headers                     = ToDictionary(httpReq.Headers),
                QueryString                 = ToDictionary(httpReq.QueryString),
                FormData                    = ToDictionary(httpReq.FormData),
                AcceptTypes                 = new List <string>(httpReq.AcceptTypes ?? new string[0]),
                ContentLength               = httpReq.ContentLength,
                OperationName               = httpReq.OperationName,
                ResponseContentType         = httpReq.ResponseContentType,
                PluginsLoaded               = HostContext.AppHost.PluginsLoaded,
                StartUpErrors               = HostContext.AppHost.StartUpErrors,
                LastRequestInfo             = LastRequestInfo,
                VirtualPathProviderFiles    = HostContext.AppHost.VirtualFileSources.GetAllMatchingFiles("*").Take(virtualPathCount).Map(x => x.RealPath),
                Stats                       = new Dictionary <string, string> {
                    { "RawHttpHandlers", HostContext.AppHost.RawHttpHandlers.Count.ToString() },
                    { "PreRequestFilters", HostContext.AppHost.PreRequestFilters.Count.ToString() },
                    { "RequestBinders", HostContext.AppHost.RequestBinders.Count.ToString() },
                    { "GlobalRequestFilters", HostContext.AppHost.GlobalRequestFilters.Count.ToString() },
                    { "GlobalResponseFilters", HostContext.AppHost.GlobalResponseFilters.Count.ToString() },
                    { "CatchAllHandlers", HostContext.AppHost.CatchAllHandlers.Count.ToString() },
                    { "Plugins", HostContext.AppHost.Plugins.Count.ToString() },
                    { "ViewEngines", HostContext.AppHost.ViewEngines.Count.ToString() },
                    { "RequestTypes", HostContext.AppHost.Metadata.RequestTypes.Count.ToString() },
                    { "ResponseTypes", HostContext.AppHost.Metadata.ResponseTypes.Count.ToString() },
                    { "ServiceTypes", HostContext.AppHost.Metadata.ServiceTypes.Count.ToString() },
                    { "RestPaths", HostContext.AppHost.RestPaths.Count.ToString() },
                    { "ContentTypes", HostContext.AppHost.ContentTypes.ContentTypeFormats.Count.ToString() },
                    { "EnableFeatures", HostContext.Config.EnableFeatures.ToString() },
                    { "VirtualPathProvider", HostContext.AppHost.VirtualFileSources.ToString() }
                },
            };

            return(response);
        }
Beispiel #2
0
        public static RequestInfoResponse GetRequestInfo(IRequest httpReq)
        {
            var response = new RequestInfoResponse
            {
                Usage                       = "append '?debug=requestinfo' to any querystring",
                Host                        = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName,
                Date                        = DateTime.UtcNow,
                ServiceName                 = HostContext.ServiceName,
                HandlerFactoryPath          = HostContext.Config.HandlerFactoryPath,
                UserHostAddress             = httpReq.UserHostAddress,
                HttpMethod                  = httpReq.Verb,
                AbsoluteUri                 = httpReq.AbsoluteUri,
                WebHostUrl                  = HostContext.Config.WebHostUrl,
                ApplicationBaseUrl          = httpReq.GetBaseUrl(),
                ResolveAbsoluteUrl          = HostContext.AppHost.ResolveAbsoluteUrl("~/resolve", httpReq),
                StripApplicationVirtualPath = HostContext.Config.StripApplicationVirtualPath,
                RawUrl                      = httpReq.RawUrl,
                ResolvedPathInfo            = httpReq.PathInfo,
                ContentType                 = httpReq.ContentType,
                Headers                     = ToDictionary(httpReq.Headers),
                QueryString                 = ToDictionary(httpReq.QueryString),
                FormData                    = ToDictionary(httpReq.FormData),
                AcceptTypes                 = new List <string>(httpReq.AcceptTypes ?? new string[0]),
                ContentLength               = httpReq.ContentLength,
                OperationName               = httpReq.OperationName,
                ResponseContentType         = httpReq.ResponseContentType,
                PluginsLoaded               = HostContext.AppHost.PluginsLoaded,
                StartUpErrors               = HostContext.AppHost.StartUpErrors,
                LastRequestInfo             = LastRequestInfo,
                VirtualPathProviderFiles    = HostContext.AppHost.VirtualPathProvider.GetAllMatchingFiles("*").Take(1000).Map(x => x.RealPath),
                Stats                       = new Dictionary <string, string> {
                    { "RawHttpHandlers", HostContext.AppHost.RawHttpHandlers.Count.ToString() },
                    { "PreRequestFilters", HostContext.AppHost.PreRequestFilters.Count.ToString() },
                    { "RequestBinders", HostContext.AppHost.RequestBinders.Count.ToString() },
                    { "GlobalRequestFilters", HostContext.AppHost.GlobalRequestFilters.Count.ToString() },
                    { "GlobalResponseFilters", HostContext.AppHost.GlobalResponseFilters.Count.ToString() },
                    { "CatchAllHandlers", HostContext.AppHost.CatchAllHandlers.Count.ToString() },
                    { "Plugins", HostContext.AppHost.Plugins.Count.ToString() },
                    { "ViewEngines", HostContext.AppHost.ViewEngines.Count.ToString() },
                    { "RequestTypes", HostContext.AppHost.Metadata.RequestTypes.Count.ToString() },
                    { "ResponseTypes", HostContext.AppHost.Metadata.ResponseTypes.Count.ToString() },
                    { "ServiceTypes", HostContext.AppHost.Metadata.ServiceTypes.Count.ToString() },
                    { "RestPaths", HostContext.AppHost.RestPaths.Count.ToString() },
                    { "ContentTypes", HostContext.AppHost.ContentTypes.ContentTypeFormats.Count.ToString() },
                    { "EnableFeatures", HostContext.Config.EnableFeatures.ToString() },
                    { "VirtualPathProvider", HostContext.AppHost.VirtualPathProvider.ToString() }
                },
            };

            return(response);
        }
Beispiel #3
0
        public static RequestInfoResponse GetRequestInfo(IRequest httpReq)
        {
            var response = new RequestInfoResponse
            {
                Host                = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName,
                Date                = DateTime.UtcNow,
                ServiceName         = HostContext.ServiceName,
                UserHostAddress     = httpReq.UserHostAddress,
                HttpMethod          = httpReq.Verb,
                AbsoluteUri         = httpReq.AbsoluteUri,
                RawUrl              = httpReq.RawUrl,
                ResolvedPathInfo    = httpReq.PathInfo,
                ContentType         = httpReq.ContentType,
                Headers             = ToDictionary(httpReq.Headers),
                QueryString         = ToDictionary(httpReq.QueryString),
                FormData            = ToDictionary(httpReq.FormData),
                AcceptTypes         = new List <string>(httpReq.AcceptTypes ?? new string[0]),
                ContentLength       = httpReq.ContentLength,
                OperationName       = httpReq.OperationName,
                ResponseContentType = httpReq.ResponseContentType,
            };

            return(response);
        }
		public static RequestInfoResponse GetRequestInfo(IRequest httpReq)
		{
			var response = new RequestInfoResponse
			{
				Host = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName,
				Date = DateTime.UtcNow,
				ServiceName = HostContext.ServiceName,
                HandlerFactoryPath = HostContext.Config.HandlerFactoryPath,
				UserHostAddress = httpReq.UserHostAddress,
				HttpMethod = httpReq.Verb,
				AbsoluteUri = httpReq.AbsoluteUri,
                ResolveAbsoluteUrl = HostContext.AppHost.ResolveAbsoluteUrl("~/resolve", httpReq),
				RawUrl = httpReq.RawUrl,
				ResolvedPathInfo = httpReq.PathInfo,
				ContentType = httpReq.ContentType,
				Headers = ToDictionary(httpReq.Headers),
				QueryString = ToDictionary(httpReq.QueryString),
				FormData = ToDictionary(httpReq.FormData),
				AcceptTypes = new List<string>(httpReq.AcceptTypes ?? new string[0]),
				ContentLength = httpReq.ContentLength,
				OperationName = httpReq.OperationName,
				ResponseContentType = httpReq.ResponseContentType,
                PluginsLoaded = HostContext.AppHost.PluginsLoaded,
                StartUpErrors = HostContext.AppHost.StartUpErrors,
                LastRequestInfo = LastRequestInfo,
                Stats = new Dictionary<string, string> {
                    {"RawHttpHandlers", HostContext.AppHost.RawHttpHandlers.Count.ToString() },
                    {"PreRequestFilters", HostContext.AppHost.PreRequestFilters.Count.ToString() },
                    {"RequestBinders", HostContext.AppHost.RequestBinders.Count.ToString() },
                    {"GlobalRequestFilters", HostContext.AppHost.GlobalRequestFilters.Count.ToString() },
                    {"GlobalResponseFilters", HostContext.AppHost.GlobalResponseFilters.Count.ToString() },
                    {"CatchAllHandlers", HostContext.AppHost.CatchAllHandlers.Count.ToString() },
                    {"Plugins", HostContext.AppHost.Plugins.Count.ToString() },
                    {"ViewEngines", HostContext.AppHost.ViewEngines.Count.ToString() },
                    {"RequestTypes", HostContext.AppHost.Metadata.RequestTypes.Count.ToString() },
                    {"ResponseTypes", HostContext.AppHost.Metadata.ResponseTypes.Count.ToString() },
                    {"ServiceTypes", HostContext.AppHost.Metadata.ServiceTypes.Count.ToString() },
                    {"RestPaths", HostContext.AppHost.RestPaths.Count.ToString() },
                    {"ContentTypes", HostContext.AppHost.ContentTypes.ContentTypeFormats.Count.ToString() },
                    {"EnableFeatures", HostContext.Config.EnableFeatures.ToString() },
                }
			};
			return response;
		}
		public static RequestInfoResponse GetRequestInfo(IHttpRequest httpReq)
		{
			var response = new RequestInfoResponse
			{
				Host = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName,
				Date = DateTime.UtcNow,
				ServiceName = HostContext.ServiceName,
				UserHostAddress = httpReq.UserHostAddress,
				HttpMethod = httpReq.HttpMethod,
				AbsoluteUri = httpReq.AbsoluteUri,
				RawUrl = httpReq.RawUrl,
				ResolvedPathInfo = httpReq.PathInfo,
				ContentType = httpReq.ContentType,
				Headers = ToDictionary(httpReq.Headers),
				QueryString = ToDictionary(httpReq.QueryString),
				FormData = ToDictionary(httpReq.FormData),
				AcceptTypes = new List<string>(httpReq.AcceptTypes ?? new string[0]),
				ContentLength = httpReq.ContentLength,
				OperationName = httpReq.OperationName,
				ResponseContentType = httpReq.ResponseContentType,
			};
			return response;
		}
        public static RequestInfoResponse GetRequestInfo(IRequest httpReq)
        {
            int.TryParse(httpReq.QueryString["virtualPathCount"], out var virtualPathCount);
            var hostType = HostContext.AppHost.GetType();

            var ipv4Addr = "";

            foreach (var entry in ServiceStackHandlerBase.NetworkInterfaceIpv4Addresses)
            {
                if (ipv4Addr.Length > 0)
                {
                    ipv4Addr += ", ";
                }
                ipv4Addr += new IPAddress(entry.Key) + "/" + new IPAddress(entry.Value);
            }

            var ipv6Address = "";

            foreach (var addr in ServiceStackHandlerBase.NetworkInterfaceIpv6Addresses)
            {
                if (ipv6Address.Length > 0)
                {
                    ipv6Address += ", ";
                }
                ipv6Address += new IPAddress(addr);
            }

            var response = new RequestInfoResponse
            {
                Usage                       = "append '?debug=requestinfo' to any querystring. Optional params: virtualPathCount",
                Host                        = HostContext.ServiceName + "_" + HostContext.Config.ApiVersion + "_" + HostContext.Config.DebugHttpListenerHostEnvironment + "_" + Env.ServerUserAgent,
                HostType                    = "{0} ({1})".Fmt(HostContext.IsAspNetHost ? "ASP.NET" : "SelfHost", hostType.BaseType?.Name ?? hostType.Name),
                StartedAt                   = HostContext.AppHost.StartedAt.ToString("yyyy-MM-dd HH:mm:ss"),
                Date                        = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"),
                ServiceName                 = HostContext.ServiceName,
                HandlerFactoryPath          = HostContext.Config.HandlerFactoryPath,
                UserHostAddress             = httpReq.UserHostAddress,
                HttpMethod                  = httpReq.Verb,
                AbsoluteUri                 = httpReq.AbsoluteUri,
                WebHostUrl                  = HostContext.Config.WebHostUrl,
                ApplicationBaseUrl          = httpReq.GetBaseUrl(),
                ResolveAbsoluteUrl          = HostContext.AppHost.ResolveAbsoluteUrl("~/resolve", httpReq),
                RootDirectoryPath           = HostContext.VirtualFileSources.RootDirectory.RealPath,
                StripApplicationVirtualPath = HostContext.Config.StripApplicationVirtualPath,
                CurrentDirectory            = Directory.GetCurrentDirectory(),
                RawUrl                      = httpReq.RawUrl,
                PathInfo                    = httpReq.PathInfo,
                OriginalPathInfo            = httpReq.OriginalPathInfo,
                ContentType                 = httpReq.ContentType,
                Headers                     = ToDictionary(httpReq.Headers),
                QueryString                 = ToDictionary(httpReq.QueryString),
                FormData                    = ToDictionary(httpReq.FormData),
                AcceptTypes                 = new List <string>(httpReq.AcceptTypes ?? TypeConstants.EmptyStringArray),
                ContentLength               = httpReq.ContentLength,
                OperationName               = httpReq.OperationName,
                ResponseContentType         = httpReq.ResponseContentType,
                RequestAttributes           = httpReq.GetAttributes().ToString(),
                Ipv4Addresses               = ipv4Addr,
                Ipv6Addresses               = ipv6Address,
                PluginsLoaded               = HostContext.AppHost.PluginsLoaded,
                StartUpErrors               = HostContext.AppHost.StartUpErrors,
                AsyncErrors                 = HostContext.AppHost.AsyncErrors,
                LastRequestInfo             = LastRequestInfo,
                VirtualPathProviderFiles    = HostContext.AppHost.VirtualFileSources.GetAllMatchingFiles("*").Take(virtualPathCount).Map(x => x.RealPath),
                Stats                       = new Dictionary <string, string> {
                    { "RawHttpHandlers", HostContext.AppHost.RawHttpHandlersArray.Length.ToString() },
                    { "PreRequestFilters", HostContext.AppHost.PreRequestFiltersArray.Length.ToString() },
                    { "RequestBinders", HostContext.AppHost.RequestBinders.Count.ToString() },
                    { "GlobalRequestFilters", HostContext.AppHost.GlobalRequestFiltersArray.Length.ToString() },
                    { "GlobalRequestFiltersAsync", HostContext.AppHost.GlobalRequestFiltersAsyncArray.Length.ToString() },
                    { "GlobalResponseFilters", HostContext.AppHost.GlobalResponseFiltersArray.Length.ToString() },
                    { "GlobalResponseFiltersAsync", HostContext.AppHost.GlobalResponseFiltersAsyncArray.Length.ToString() },
                    { "CatchAllHandlers", HostContext.AppHost.CatchAllHandlersArray.Length.ToString() },
                    { "Plugins", HostContext.AppHost.Plugins.Count.ToString() },
                    { "ViewEngines", HostContext.AppHost.ViewEngines.Count.ToString() },
                    { "RequestTypes", HostContext.AppHost.Metadata.RequestTypes.Count.ToString() },
                    { "ResponseTypes", HostContext.AppHost.Metadata.ResponseTypes.Count.ToString() },
                    { "ServiceTypes", HostContext.AppHost.Metadata.ServiceTypes.Count.ToString() },
                    { "RestPaths", HostContext.AppHost.RestPaths.Count.ToString() },
                    { "ContentTypes", HostContext.AppHost.ContentTypes.ContentTypeFormats.Count.ToString() },
                    { "EnableFeatures", HostContext.Config.EnableFeatures.ToString() },
                    { "VirtualPathProvider", HostContext.AppHost.VirtualFileSources.ToString() }
                },
            };

            return(response);
        }
        public static RequestInfoResponse GetRequestInfo(IRequest httpReq)
        {
            int virtualPathCount = 0;
            int.TryParse(httpReq.QueryString["virtualPathCount"], out virtualPathCount);
            var hostType = HostContext.AppHost.GetType();

            var response = new RequestInfoResponse
            {
                Usage = "append '?debug=requestinfo' to any querystring. Optional params: virtualPathCount",
                Host = HostContext.Config.DebugHttpListenerHostEnvironment + "_v" + Env.ServiceStackVersion + "_" + HostContext.ServiceName,
                HostType = "{0} ({1})".Fmt(HostContext.IsAspNetHost ? "ASP.NET" : "SelfHost", hostType.BaseType != null ? hostType.BaseType.Name : hostType.Name),
                Date = DateTime.UtcNow.ToString("yy-MM-dd HH:mm:ss"),
                ServiceName = HostContext.ServiceName,
                HandlerFactoryPath = HostContext.Config.HandlerFactoryPath,
                UserHostAddress = httpReq.UserHostAddress,
                HttpMethod = httpReq.Verb,
                AbsoluteUri = httpReq.AbsoluteUri,
                WebHostUrl = HostContext.Config.WebHostUrl,
                ApplicationBaseUrl = httpReq.GetBaseUrl(),
                ResolveAbsoluteUrl = HostContext.AppHost.ResolveAbsoluteUrl("~/resolve", httpReq),
                RootDirectoryPath = HostContext.VirtualFileSources.RootDirectory.RealPath,
                StripApplicationVirtualPath = HostContext.Config.StripApplicationVirtualPath,
                CurrentDirectory = Directory.GetCurrentDirectory(),
                RawUrl = httpReq.RawUrl,
                ResolvedPathInfo = httpReq.PathInfo,
                ContentType = httpReq.ContentType,
                Headers = ToDictionary(httpReq.Headers),
                QueryString = ToDictionary(httpReq.QueryString),
                FormData = ToDictionary(httpReq.FormData),
                AcceptTypes = new List<string>(httpReq.AcceptTypes ?? new string[0]),
                ContentLength = httpReq.ContentLength,
                OperationName = httpReq.OperationName,
                ResponseContentType = httpReq.ResponseContentType,
                PluginsLoaded = HostContext.AppHost.PluginsLoaded,
                StartUpErrors = HostContext.AppHost.StartUpErrors,
                LastRequestInfo = LastRequestInfo,
                VirtualPathProviderFiles = HostContext.AppHost.VirtualFileSources.GetAllMatchingFiles("*").Take(virtualPathCount).Map(x => x.RealPath),
                Stats = new Dictionary<string, string> {
                    {"RawHttpHandlers", HostContext.AppHost.RawHttpHandlers.Count.ToString() },
                    {"PreRequestFilters", HostContext.AppHost.PreRequestFilters.Count.ToString() },
                    {"RequestBinders", HostContext.AppHost.RequestBinders.Count.ToString() },
                    {"GlobalRequestFilters", HostContext.AppHost.GlobalRequestFilters.Count.ToString() },
                    {"GlobalResponseFilters", HostContext.AppHost.GlobalResponseFilters.Count.ToString() },
                    {"CatchAllHandlers", HostContext.AppHost.CatchAllHandlers.Count.ToString() },
                    {"Plugins", HostContext.AppHost.Plugins.Count.ToString() },
                    {"ViewEngines", HostContext.AppHost.ViewEngines.Count.ToString() },
                    {"RequestTypes", HostContext.AppHost.Metadata.RequestTypes.Count.ToString() },
                    {"ResponseTypes", HostContext.AppHost.Metadata.ResponseTypes.Count.ToString() },
                    {"ServiceTypes", HostContext.AppHost.Metadata.ServiceTypes.Count.ToString() },
                    {"RestPaths", HostContext.AppHost.RestPaths.Count.ToString() },
                    {"ContentTypes", HostContext.AppHost.ContentTypes.ContentTypeFormats.Count.ToString() },
                    {"EnableFeatures", HostContext.Config.EnableFeatures.ToString() },
                    {"VirtualPathProvider", HostContext.AppHost.VirtualFileSources.ToString() }
                },
            };
            return response;
        }