Esempio n. 1
0
 public HttpResponse(HttpStatusLine statusLine, HttpHeaders headers, byte[] body, HttpHeaders trailers)
 {
     this.StatusLine = statusLine ?? HttpStatusLine.Empty;
     this.Headers    = headers ?? HttpHeaders.Empty;;
     this.Body       = body;
     this.Trailers   = trailers ?? HttpHeaders.Empty;;
 }
Esempio n. 2
0
 /// <summary>
 /// 解析(要改行)
 /// </summary>
 /// <param name="source"></param>
 /// <param name="statusLine"></param>
 /// <returns></returns>
 public static bool TryParse(string source, out HttpStatusLine statusLine)
 {
     try
     {
         var groups       = pattern.Match(source).Groups;
         var version      = new Version(int.Parse(groups[1].Value), int.Parse(groups[2].Value));
         var statusCode   = (HttpStatusCode)int.Parse(groups[3].Value);
         var reasonPhrase = groups[4].Value;  // reason-phrase の手前の SP は省略できないはずだが、実際には省略してくるサーバーがいる
         statusLine = new HttpStatusLine(version, statusCode, reasonPhrase, source);
         return(true);
     }
     catch (Exception)
     {
         statusLine = new HttpStatusLine(null, 0, null, source);
         return(false);
     }
 }