HTTP服务器软件系统的设计与实现(21)_毕业论文

毕业论文移动版

毕业论文 > 计算机论文 >

HTTP服务器软件系统的设计与实现(21)


                string extension = filepats[filepats.Length - 1];
                return GetContentTypeByExtension(extension);
            }
            else
                return MimeType.none;
        }


        public static string GetStringMimeType(MimeType mime)
        {
            string strMime = "";
            switch (mime)
            {
                case MimeType.text_html: strMime = "text/html; charset=utf-8"; break;
                case MimeType.text_javascript: strMime = "text/javascript"; break;
                case MimeType.multipart_xmixedreplace:
                    strMime = "multipart/x-mixed-replace; boundary=rnA00A"; break;
                case MimeType.application_xml_charsetutf8:
                    strMime = "application/xml; charset=utf-8";
                    break;
                default:
                    strMime = mime.ToString().Replace("_", "/");
                    break;
            }
            return strMime;
        }

        public static MimeType GetContentTypeByExtension(string extension)
        {
            switch (extension)
            {
                case "css":
                    return MimeType.text_css;
                case "gif":
                    return MimeType.image_gif;
                case "jpg":
                case "jpeg":
                    return MimeType.image_jpeg; (责任编辑:qin)