コード例 #1
0
 /// <summary>
 /// Returns the type of this message
 /// </summary>
 public static HttpMessageTypes TypeOf(string firstLine)
 {
     try
     {
         // requests are more common so we'll try that first
         HttpRequestLine requestLine = HttpRequestLine.Parse(firstLine);
         return(HttpMessageTypes.HttpRequest);
     }
     catch
     {
         try
         {
             // followed closely by responses
             HttpStatusLine statusLine = HttpStatusLine.Parse(firstLine);
             return(HttpMessageTypes.HttpResponse);
         }
         catch
         {
             // hmmm, it somehow was parsed into a message but we can't figure out what the hell it is
             // so we're going to say it's an unknown type
             return(HttpMessageTypes.Unknown);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the HttpResponse class
        /// </summary>
        /// <param name="message"></param>
        public HttpResponse(HttpMessage message) : base(message)
        {
            _statusLine = HttpStatusLine.Parse(base.FirstLine);
//			this.InitHeaders(); // no very bad!!! using a message as a constructor means we've received a message and we're creating a response around it, so it will already have headers!!!
        }
コード例 #3
0
 /// <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();
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the HttpResponse class
 /// </summary>
 public HttpResponse() : base()
 {
     _statusLine = new HttpStatusLine(new OkStatus());             // 200 OK
     this.InitHeaders();
 }
コード例 #5
0
		/// <summary>
		/// Initializes a new instance of the HttpResponse class
		/// </summary>
		/// <param name="message"></param>
		public HttpResponse(HttpMessage message) : base(message)
		{
			_statusLine = HttpStatusLine.Parse(base.FirstLine);
//			this.InitHeaders(); // no very bad!!! using a message as a constructor means we've received a message and we're creating a response around it, so it will already have headers!!!
		}
コード例 #6
0
		/// <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();
		}
コード例 #7
0
		/// <summary>
		/// Initializes a new instance of the HttpResponse class
		/// </summary>
		public HttpResponse() : base()
		{
			_statusLine = new HttpStatusLine(new OkStatus()); // 200 OK
			this.InitHeaders();
		}