Example #1
0
        protected override string GetContentTypeCore()
        {
            var    extension   = Path.GetExtension(_fullPath).ToLower();
            string contentType = CefRuntime.GetMimeTypeForExtension(extension);

            if (string.IsNullOrEmpty(contentType))
            {
                _contentTypesByFileEnding.TryGetValue(extension, out contentType);
            }
            return(string.IsNullOrEmpty(contentType) ? MediaTypeNames.Application.Octet : contentType);
        }
        private static string GetContentType(string packageFile)
        {
            var ext = Path.GetExtension(packageFile);

            if (_contentTypesGiven.Count > 0 && _contentTypesGiven.ContainsKey(ext))
            {
                return(_contentTypesGiven[ext]);
            }

            var type = CefRuntime.GetMimeTypeForExtension(ext);

            if (type != null)
            {
                return(type);
            }

            switch (ext)
            {
            case ".html":
            case ".htm":
                return("text/html");

            case ".js":
                return("text/javascript");

            case ".css":
                return("text/css");

            case ".json":
                return("application/json");

            case ".png":
                return("image/png");

            case ".gif":
                return("image/gif");

            case ".ico":
                return("image/vnd.microsoft.icon");

            case ".jpg":
            case ".jpeg":
                return("image/jpeg");

            case ".mp3":
                return("audio/mpeg3");

            case ".xml":
                return("application/xml");

            case ".svg":
                return("image/svg+xml");

            case ".ttf":
                return("application/x-font-ttf");

            case ".eot":
                return("application/vnd.ms-fontobject");

            case ".woff":
                return("application/x-woff");

            default:
                return(MediaTypeNames.Application.Octet);
            }
        }