GetReasonPhrase() 공개 정적인 메소드

public static GetReasonPhrase ( int status_code ) : string
status_code int
리턴 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\"");
     }
 }