GetReasonPhrase() public static method

public static GetReasonPhrase ( int status_code ) : string
status_code int
return string
示例#1
0
        public HTTPResponse(
            string protocol,
            HttpStatusCode status,
            IDictionary <string, string> headers,
            string body)
        {
            this.Protocol     = protocol;
            this.Status       = (int)status;
            this.ReasonPhrase = HTTPUtils.GetReasonPhrase(this.Status);
            this.Headers      = new Dictionary <string, string>(headers, StringComparer.OrdinalIgnoreCase);
            var mem = new MemoryStream();

            using (var writer = new StreamWriter(mem)) {
                writer.Write(body);
            }
            this.Body = mem.ToArray();
            if (!Headers.ContainsKey("Content-Type"))
            {
                Headers.Add("Content-Type", "text/plain");
            }
            if (status == HttpStatusCode.Unauthorized && !Headers.ContainsKey("WWW-Authenticate"))
            {
                Headers.Add("WWW-Authenticate", "Basic realm=\"PeerCastStation\"");
            }
        }
示例#2
0
 public HTTPResponse(
     string protocol,
     int status,
     string reason_phrase,
     IDictionary <string, string> headers,
     byte[] body)
 {
     this.Protocol     = protocol;
     this.Status       = status;
     this.ReasonPhrase = reason_phrase ?? HTTPUtils.GetReasonPhrase(status);
     this.Headers      = new Dictionary <string, string>(headers, StringComparer.OrdinalIgnoreCase);
     this.Body         = body;
 }
示例#3
0
 public HTTPResponse(
     string protocol,
     HttpStatusCode status)
 {
     this.Protocol     = protocol;
     this.Status       = (int)status;
     this.ReasonPhrase = HTTPUtils.GetReasonPhrase(this.Status);
     this.Headers      = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
     this.Body         = null;
     if (status == HttpStatusCode.Unauthorized && !Headers.ContainsKey("WWW-Authenticate"))
     {
         Headers.Add("WWW-Authenticate", "Basic realm=\"PeerCastStation\"");
     }
 }