public static void WriteHTTPResponseHeader(this Stream stream, int code, string contentType, long contentLength) { stream.WriteUTF8(string.Format("HTTP/1.0 {0} {1}\r\n", code, HttpStatusCode.GetName(typeof(HttpStatusCode), code) ?? "UNKNOWN")); stream.WriteUTF8("Content-Type: " + contentType + "\r\n"); if (contentLength > 0) { stream.WriteUTF8("Content-Length: " + contentLength.ToString(CultureInfo.InvariantCulture) + "\r\n"); } }
public MeisterStatus(IRestResponse response, string endpoint) { if (response != null && response.ResponseUri != null) { StatusCode = response.StatusCode; StatusCodeDescription = response.StatusDescription; LogEntry = response.Content; OriginalUrl = response.ResponseUri.AbsoluteUri; FromEndpoint = endpoint; if (LogEntry.Contains("<?xml")) { XmlDocument doc = new XmlDocument(); doc.LoadXml(LogEntry); LogEntry = JsonConvert.SerializeXmlNode(doc); } } else if (response != null) { StatusCode = HttpStatusCode.ServiceUnavailable; StatusCodeDescription = HttpStatusCode.GetName(typeof(HttpStatusCode), StatusCode); FromEndpoint = endpoint; OriginalUrl = response.Request.Resource; } }