/// <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 HttpStatusLine class /// </summary> /// <param name="status"></param> public HttpStatusLine(HttpStatus status) : this(new HttpProtocolVersion(), status) { }
/// <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); }
/// <summary> /// Initializes a new instance of the HttpResponse class /// </summary> /// <param name="status"></param> public HttpResponse(HttpStatus status) : base() { _statusLine = new HttpStatusLine(status); this.InitHeaders(); }