/// Parses the <paramref name="data"/> provided into either a <see cref="System.Net.Http.HttpRequestMessage"/> or <see cref="System.Net.Http.HttpResponseMessage"/> object.
/// </summary>
/// <param name="data">A string containing the HTTP message to parse.</param>
/// <returns>Either a <see cref="System.Net.Http.HttpRequestMessage"/> or <see cref="System.Net.Http.HttpResponseMessage"/> object containing the parsed data.</returns>
publicabstractTParse(stringdata);
/// <summary>
/// Parses a string containing either an HTTP request or response into a <see cref="System.Net.Http.HttpRequestMessage"/> or <see cref="System.Net.Http.HttpResponseMessage"/> object.
/// </summary>
/// <param name="message">A <see cref="System.Net.Http.HttpRequestMessage"/> or <see cref="System.Net.Http.HttpResponseMessage"/> object representing the parsed message.</param>
/// <param name="headers">A reference to the <see cref="System.Net.Http.Headers.HttpHeaders"/> collection for the <paramref name="message"/> object.</param>
/// <param name="data">A string containing the data to be parsed.</param>
/// <returns>An <see cref="System.Net.Http.HttpContent"/> object containing the content of the parsed message.</returns>
if(data.Length==0)thrownewArgumentException("data cannot be an empty string.",nameof(data));
if(!LineTerminators.Any(data.Contains))thrownewArgumentException("data is not a valid request, it does not contain any CRLF/LF terminators.",nameof(data));
//First line is the 'request' line containing http protocol details like method, uri, http version etc.
ParseStatusLine(lines[0],message);
ParseHeaders(headers,retVal.Headers,lines);
}
}
/// <summary>
/// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the <paramref name="message"/>.
/// </summary>
/// <param name="data">The first line of the HTTP message to be parsed.</param>
/// <param name="message">Either a <see cref="System.Net.Http.HttpResponseMessage"/> or <see cref="System.Net.Http.HttpRequestMessage"/> to assign the parsed values to.</param>
/// Parses the HTTP version text from an HTTP request or response status line and returns a <see cref="Version"/> object representing the parsed values.
/// </summary>
/// <param name="versionData">A string containing the HTTP version, from the message status line.</param>
/// <returns>A <see cref="Version"/> object containing the parsed version data.</returns>
if(versionSeparatorIndex<=0||versionSeparatorIndex==versionData.Length)thrownewArgumentException("request header line is invalid. Http Version not supplied or incorrect format.",nameof(versionData));
/// Parses a line from an HTTP request or response message containing a header name and value pair.
/// </summary>
/// <param name="line">A string containing the data to be parsed.</param>
/// <param name="headers">A reference to a <see cref="System.Net.Http.Headers.HttpHeaders"/> collection to which the parsed header will be added.</param>
/// <param name="contentHeaders">A reference to a <see cref="System.Net.Http.Headers.HttpHeaders"/> collection for the message content, to which the parsed header will be added.</param>