HttpServer.Modules.FileModule.AddDefaultMimeTypes C# (CSharp) Method

AddDefaultMimeTypes() public method

Mime types that this class can handle per default
Contains the following mime types:
public AddDefaultMimeTypes ( ) : void
return void
        public void AddDefaultMimeTypes()
        {
            ContentTypes.Add("default", new ContentTypeHeader("application/octet-stream"));
            ContentTypes.Add("txt", new ContentTypeHeader("text/plain"));
            ContentTypes.Add("html", new ContentTypeHeader("text/html"));
            ContentTypes.Add("htm", new ContentTypeHeader("text/html"));
            ContentTypes.Add("jpg", new ContentTypeHeader("image/jpg"));
            ContentTypes.Add("jpeg", new ContentTypeHeader("image/jpg"));
            ContentTypes.Add("bmp", new ContentTypeHeader("image/bmp"));
            ContentTypes.Add("gif", new ContentTypeHeader("image/gif"));
            ContentTypes.Add("png", new ContentTypeHeader("image/png"));

            ContentTypes.Add("ico", new ContentTypeHeader("image/vnd.microsoft.icon"));
            ContentTypes.Add("css", new ContentTypeHeader("text/css"));
            ContentTypes.Add("gzip", new ContentTypeHeader("application/x-gzip"));
            ContentTypes.Add("zip", new ContentTypeHeader("multipart/x-zip"));
            ContentTypes.Add("tar", new ContentTypeHeader("application/x-tar"));
            ContentTypes.Add("pdf", new ContentTypeHeader("application/pdf"));
            ContentTypes.Add("rtf", new ContentTypeHeader("application/rtf"));
            ContentTypes.Add("xls", new ContentTypeHeader("application/vnd.ms-excel"));
            ContentTypes.Add("ppt", new ContentTypeHeader("application/vnd.ms-powerpoint"));
            ContentTypes.Add("doc", new ContentTypeHeader("application/application/msword"));
            ContentTypes.Add("js", new ContentTypeHeader("application/javascript"));
            ContentTypes.Add("au", new ContentTypeHeader("audio/basic"));
            ContentTypes.Add("snd", new ContentTypeHeader("audio/basic"));
            ContentTypes.Add("es", new ContentTypeHeader("audio/echospeech"));
            ContentTypes.Add("mp3", new ContentTypeHeader("audio/mpeg"));
            ContentTypes.Add("mp2", new ContentTypeHeader("audio/mpeg"));
            ContentTypes.Add("mid", new ContentTypeHeader("audio/midi"));
            ContentTypes.Add("wav", new ContentTypeHeader("audio/x-wav"));
            ContentTypes.Add("swf", new ContentTypeHeader("application/x-shockwave-flash"));
            ContentTypes.Add("avi", new ContentTypeHeader("video/avi"));
            ContentTypes.Add("rm", new ContentTypeHeader("audio/x-pn-realaudio"));
            ContentTypes.Add("ram", new ContentTypeHeader("audio/x-pn-realaudio"));
            ContentTypes.Add("aif", new ContentTypeHeader("audio/x-aiff"));
        }

Usage Example

示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleServer"/> class.
        /// </summary>
        public SimpleServer()
        {
            Add(new BodyDecoders.MultiPartDecoder());
            Add(new BodyDecoders.UrlDecoder());

            var fileModule = new FileModule();
            fileModule.AddDefaultMimeTypes();
            AddEmbeddedResources(Assembly.GetCallingAssembly(), fileModule);
            AddFileResources(Assembly.GetCallingAssembly(), fileModule);
        }