public SitkaDebugInfo(HttpRequest request) { var requestContent = HttpDebugInfo.GetRequestContent(request); var hostnameByReverseDns = String.Empty; var whoisInfo = String.Empty; IPAddress userHostIpAddress = null; if (request.UserHostAddress != null) { userHostIpAddress = IPAddress.Parse(request.UserHostAddress); hostnameByReverseDns = DnsUtility.GetReverseDns(userHostIpAddress); whoisInfo = WhoisUtility.Lookup(userHostIpAddress); } IpAddress = userHostIpAddress; Hostname = hostnameByReverseDns ?? String.Empty; WhoIsInfo = whoisInfo ?? String.Empty; Uri = request.Url; RequestInfo = requestContent ?? String.Empty; }
public SitkaDebugInfo(HttpRequest request, string cookiePrefixToExcludeFromEmailLogging) { var requestContent = HttpDebugInfo.GetRequestContent(request); requestContent = SanitizeRequestContent(request, cookiePrefixToExcludeFromEmailLogging, requestContent); var hostnameByReverseDns = String.Empty; var whoisInfo = String.Empty; IPAddress userHostIpAddress = null; if (request.UserHostAddress != null) { userHostIpAddress = IPAddress.Parse(request.UserHostAddress); hostnameByReverseDns = DnsUtility.GetReverseDns(userHostIpAddress); whoisInfo = WhoisUtility.Lookup(userHostIpAddress); } IpAddress = userHostIpAddress; Hostname = hostnameByReverseDns ?? String.Empty; WhoIsInfo = whoisInfo ?? String.Empty; Uri = request.Url; RequestInfo = requestContent ?? String.Empty; }
public static string DebugInfo(HttpRequest request) { var requestContent = HttpDebugInfo.GetRequestContent(request); var orgContentLength = requestContent.Length; var maxContentLength = SitkaWebConfiguration.DebugInfoMaxLength ?? orgContentLength; var newContentLength = Math.Min(maxContentLength, orgContentLength); requestContent = requestContent.Substring(0, newContentLength); var requestTruncated = orgContentLength > newContentLength; var truncationWarning = requestTruncated ? string.Format("{0}... Debug Info truncated to {1} characters", Environment.NewLine, newContentLength) : string.Empty; var rdns = String.Empty; var whoisInfo = String.Empty; if (request.UserHostAddress != null) { var userHostIpAddress = IPAddress.Parse(request.UserHostAddress); rdns = DnsUtility.GetReverseDns(userHostIpAddress); whoisInfo = CommonUtility.IndentLinesInStringByAmount(WhoisUtility.Lookup(userHostIpAddress), 12, " "); } return(String.Format("IP Address: {1}{0}Hostname: {2}{0}Whois Info: {0}{3}{0}URL: {4}{0}{0}Begin Http Request:-->{0}{5}{6}{0}<--End Http Request", Environment.NewLine, request.UserHostAddress, rdns, whoisInfo, request.Url.AbsoluteUri, requestContent, truncationWarning)); }