private string GetHeaderSummary(IntPtr connId, string sep, int sepCount, bool withContentLength) { string sep1 = ""; for (int i = 0; i < sepCount; i++) { sep1 += sep; } string sep2 = sep1; sep2 += sep; StringBuilder result = new StringBuilder(); HttpUrlField urlFieldSet = httpsServer.GetUrlFieldSet(connId); result.AppendFormat("{0}[URL Fields]\r\n", sep1); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "SCHEMA", httpsServer.GetUrlField(connId, HttpUrlField.Schema)); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "HOST", httpsServer.GetUrlField(connId, HttpUrlField.Host)); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "PORT", httpsServer.GetUrlField(connId, HttpUrlField.Port)); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "PATH", httpsServer.GetUrlField(connId, HttpUrlField.Path)); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "QUERY", httpsServer.GetUrlField(connId, HttpUrlField.QueryString)); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "FRAGMENT", httpsServer.GetUrlField(connId, HttpUrlField.Fragment)); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "USERINFO", httpsServer.GetUrlField(connId, HttpUrlField.UserInfo)); var headers = httpsServer.GetAllHeaders(connId); result.AppendFormat("{0}[Request Headers]\r\n", sep1); if (headers.Count == 0) { result.AppendFormat("{0}(no header)\r\n", sep2); } else { foreach (var item in headers) { result.AppendFormat("{0}{1}: {2}\r\n", sep2, item.Name, item.Value); } } var cookies = httpsServer.GetAllCookies(connId); result.AppendFormat("{0}[Cookies]\r\n", sep1); if (cookies.Count == 0) { result.AppendFormat("{0}(no cookie)\r\n", sep2); } else { foreach (var item in cookies) { result.AppendFormat("{0}{1}: {2}\r\n", sep2, item.Name, item.Value); } } var httpVersion = httpsServer.GetVersion(connId); var upgType = httpsServer.GetUpgradeType(connId); result.AppendFormat("{0}[Basic Info]\r\n", sep1); result.AppendFormat("{0}{1}: {2}.{3}\r\n", sep2, "Version", httpVersion.LOBYTE(), httpVersion.HIBYTE()); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "Method", httpsServer.GetMethod(connId)); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "IsUpgrade", upgType != HttpUpgradeType.None); if (upgType != HttpUpgradeType.None) { result.AppendFormat("{0}{1}: {2}\r\n", sep2, "UpgradeType", upgType); } var keepAlive = httpsServer.IsKeepAlive(connId); result.AppendFormat("{0}{1}: {2}\r\n", sep2, "IsKeepAlive", keepAlive); if (withContentLength) { result.AppendFormat("{0}{1}: {2}\r\n", sep2, "ContentLength", httpsServer.GetContentLength(connId)); } result.AppendFormat("{0}{1}: {2}\r\n", sep2, "ContentType", httpsServer.GetContentType(connId)); return(result.ToString()); }