/// <summary>Parses a given string as a <see cref="RequestInfo" />.</summary>
/// <param name="method">Method of the request.</param>
/// <param name="url">URL of the request.</param>
/// <param name="message">Request content.</param>
/// <returns>Instance of the <see cref="RequestInfo" />.</returns>
public static RequestInfo Parse(Verb method, HttpUrl url, string message)
{
if (method == null)
{
throw new ArgumentNullException("method");
}
if (url == null)
{
throw new ArgumentNullException("url");
}
if (!url.IsAbsolute)
{
throw new ArgumentOutOfRangeException("url");
}
if (message == null)
{
throw new ArgumentNullException("message");
}
if (message.Length == 0)
{
throw new ArgumentOutOfRangeException("message");
}
string[] parts = Regex.Split(message, "\r\n\r\n");
Encoding encoding = Encoding.UTF8;
HeaderCollection headers = HeaderCollection.Parse(parts[0]);
return(new RequestInfo(method, url, (parts.Length > 1 ? new MemoryStream(encoding.GetBytes(parts[1].Trim('\r', '\n'))) : new MemoryStream()), new BasicClaimBasedIdentity(), headers));
}