示例#1
0
        static void WriteResponse(HttpListenerContext context, FileInfo info)
        {
            bool compress = false;

            context.Response.ContentType = WebServer.GetMimeType(info);
            if (WebServer.CompressExtentions.IndexOf(info.Extension, StringComparison.OrdinalIgnoreCase) >= 0)
            {
                string contentEncoding = context.Request.Headers["Accept-Encoding"] ?? "none";
                compress = contentEncoding.Contains("gzip");
            }
            FileStream file = new FileStream(info.FullName, FileMode.Open, FileAccess.Read);

            WebServer.WriteResponse(context, file, compress);
            file.Close();
        }
示例#2
0
 static string GetMimeType(string filename)
 {
     return(WebServer.GetMimeType(new FileInfo(filename)));
 }