/// <summary> /// Create a status from custom headers like (cs-status-code) /// </summary> /// <param name="headers"> /// A <see cref="WebHeaderCollection"/> /// </param> /// <param name="prefix"> /// A <see cref="System.String"/> with the prefix (prefix-status-code) /// </param> /// <returns> /// A <see cref="Status"/> /// </returns> public static HttpRequestStatus FromHeaders(WebHeaderCollection headers, string prefix) { string code = String.Format("{0}-status-code", prefix); string msg = String.Format("{0}-status-message", prefix); HttpRequestStatus s = new HttpRequestStatus(Convert.ToInt32(headers[code]), headers[msg]); return s; }
/// <summary> /// Create a Status instance from a string /// </summary> /// <param name="input"> /// A <see cref="System.String"/> with an HTML compliant status message /// </param> /// <returns> /// A <see cref="Status"/> with the code and message /// </returns> public static HttpRequestStatus FromString(string input) { string[] x = input.Split(new char[]{' '}, 2); HttpRequestStatus s = new HttpRequestStatus(Convert.ToInt32(x[0]), x[1]); x = null; return s; }