Beispiel #1
0
        /// <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 '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(' ');

            if (parts.Length < 3)
            {
                return(null);
            }

            HttpProtocolVersion protocolVersion = HttpProtocolVersion.Parse(parts[2]);

            if (protocolVersion == null)
            {
                return(null);
            }

            return(new HttpRequestLine(parts[0], parts[1], protocolVersion));
        }
Beispiel #3
0
        /// <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)
        {
            //value = HttpUtils.StripCRLF(value);
            //string[] parts = value.Split(HttpControlChars.SP);

            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);

            if (status == null)
            {
                return(null);
            }

            return(new HttpStatusLine(protocolVersion, 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="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="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, HttpStatusCode code, string reason)
		{
			this.ProtocolVersion = protocolVersion;
			_status = new HttpStatus(code, reason);			
		}
Beispiel #8
0
 /// <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, HttpStatusCode code, string reason)
 {
     this.ProtocolVersion = protocolVersion;
     _status = new HttpStatus(code, reason);
 }
		/// <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);
		}