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(); }
static string GetMimeType(string filename) { return(WebServer.GetMimeType(new FileInfo(filename))); }