Пример #1
0
 public static void any_header(
     Websvc w,
     string content,
     string reason,
     int content_len,
     bool ischunked)
 {
     w.out_chunked = false;
     w.need_length = false;
     if (Ini.istrue(En.debug_http))
     {
         clib.imsg("http: response: {0}", (object)reason);
     }
     Web.imsg("http: response: {0}", (object)reason);
     Web.wh(w, string.Format("HTTP/1.{0} {1}\r\n", (object)w.httpversion, (object)reason));
     Web.wh(w, "Server: DManager\r\n");
     Web.wh(w, "MIME-version: 1.0\r\n");
     if (w.isdav)
     {
         Web.wh(w, "DAV: 1,2\r\n");
         Web.wh(w, "Allow: GET, PUT, DELETE, MKCOL, OPTIONS, COPY, MOVE, PROPFIND, PROPPATCH, LOCK, UNLOCK\r\n");
         Web.wh(w, "Connection: keep-alive\r\n");
         Web.wh(w, "Pragma: no-cache\r\n");
         Web.wh(w, "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n");
     }
     if (content.Contains("text/html"))
     {
         content += "; charset=utf-8";
     }
     Web.wh(w, "Content-Type: {0}\r\n", (object)content);
     w.need_length = true;
     w.need_blank  = true;
     if (content_len >= 0)
     {
         Web.wh(w, "Content-Length: {0}\r\n", (object)content_len);
         w.need_length = false;
     }
     else if (w.httpversion == 1 && ischunked)
     {
         Web.wh(w, "Transfer-Encoding: chunked\r\n");
         w.out_chunked = true;
     }
 }