/// <summary> /// Parses a string in the format 'Method SP Request-Uri SP Http-Version CRLF' into an HttpRequestLine instance /// </summary> /// <param name="value">The string to parse. May contain CRLF.</param> /// <returns></returns> public static HttpRequestLine Parse(string value) { string[] parts = value.Split(' '); HttpProtocolVersion protocolVersion = HttpProtocolVersion.Parse(parts[2]); return(new HttpRequestLine(parts[0], parts[1], protocolVersion)); }
/// <summary> /// Initializes a new instance of the HttpStatusLine class /// </summary> /// <param name="protocolVersion">The protocol version in use</param> /// <param name="status">The status-code and reason-phrase</param> public HttpStatusLine(HttpProtocolVersion protocolVersion, HttpStatus status) { if (protocolVersion == null) throw new ArgumentNullException("protocolVersion"); if (status == null) throw new ArgumentNullException("status"); _protocolVersion = protocolVersion; _status = status; }
/// <summary> /// Parses a string in the format 'HTTP-Version SP Status-Code SP Reason-Phrase CRLF' into an HttpStatusLine instance /// </summary> /// <example> /// HTTP/1.1 200 OK\r\n /// </example> /// <param name="value">The string to parse. May contain CRLF.</param> /// <returns></returns> public static HttpStatusLine Parse(string value) { int firstSpace = value.IndexOf(HttpControlChars.SP, 0); string a = value.Substring(0, firstSpace); string b = value.Substring(++firstSpace); HttpProtocolVersion protocolVersion = HttpProtocolVersion.Parse(a); HttpStatus status = HttpStatus.Parse(b); return(new HttpStatusLine(protocolVersion, status)); }
/// <summary> /// Initializes a new instance of the HttpStatusLine class /// </summary> /// <param name="protocolVersion">The protocol version in use</param> /// <param name="status">The status-code and reason-phrase</param> public HttpStatusLine(HttpProtocolVersion protocolVersion, HttpStatus status) { if (protocolVersion == null) { throw new ArgumentNullException("protocolVersion"); } if (status == null) { throw new ArgumentNullException("status"); } _protocolVersion = protocolVersion; _status = status; }
/// <summary> /// Initializes a new instance of the HttpRequestLine class /// </summary> /// <param name="method">The method of the request</param> /// <param name="requestUri">The request-uri</param> /// <param name="protocolVersion">The protocol version</param> public HttpRequestLine(string method, string requestUri, HttpProtocolVersion protocolVersion) { this.Method = method; this.RequestUri = requestUri; this.ProtocolVersion = protocolVersion; }
/// <summary> /// Initializes a new instance of the HttpRequestLine class /// </summary> /// <param name="method">The method of the request</param> /// <param name="requestUri">The request-uri</param> /// <param name="protocolVersion">The protocol version</param> public HttpRequestLine(string method, string requestUri, string protocolVersion) { this.Method = method; this.RequestUri = requestUri; _protocolVersion = new HttpProtocolVersion(protocolVersion); }
/// <summary> /// Initializes a new instance of the HttpStatusLine class /// </summary> /// <param name="protocolVersion">The protocol version in use</param> /// <param name="code">The status-code of the response</param> /// <param name="reason">The reason-phrase to describe the status-code</param> public HttpStatusLine(HttpProtocolVersion protocolVersion, int code, string reason) { this.ProtocolVersion = protocolVersion; _status = new HttpStatus(code, reason); }