123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- //------------------------------------------------------------------------------
- // 此代码版权(除特别声明或在XREF结尾的命名空间的代码)归作者本人若汝棋茗所有
- // 源代码使用协议遵循本仓库的开源协议及附加协议,若本仓库没有设置,则按MIT开源协议授权
- // CSDN博客:https://blog.csdn.net/qq_40374647
- // 哔哩哔哩视频:https://space.bilibili.com/94253567
- // Gitee源代码仓库:https://gitee.com/RRQM_Home
- // Github源代码仓库:https://github.com/RRQM
- // API首页:https://www.yuque.com/rrqm/touchsocket/index
- // 交流QQ群:234762506
- // 感谢您的下载和使用
- //------------------------------------------------------------------------------
- //------------------------------------------------------------------------------
- namespace TouchSocket.Http
- {
- /// <summary>
- /// Http工具
- /// </summary>
- public static class HttpTools
- {
- /// <summary>
- /// 从扩展名获取ContentType
- /// </summary>
- /// <param name="extension"></param>
- /// <returns></returns>
- public static string GetContentTypeFromExtension(string extension)
- {
- switch (extension.ToLower())
- {
- case ".html":
- return "text/html";
- case ".css":
- return "text/css";
- case ".js":
- return "text/javascript";
- case ".xml":
- return "text/xml";
- case ".gzip":
- return "application/gzip";
- case ".json":
- return "application/json";
- case ".map":
- return "application/json";
- case ".pdf":
- return "application/pdf";
- case ".zip":
- return "application/zip";
- case ".mp3":
- return "audio/mpeg";
- case ".jpg":
- return "image/jpeg";
- case ".gif":
- return "image/gif";
- case ".png":
- return "image/png";
- case ".svg":
- return "image/svg+xml";
- case ".mp4":
- return "video/mp4";
- case ".atom":
- return "application/atom+xml";
- case ".fastsoap":
- return "application/fastsoap";
- case ".ps":
- return "application/postscript";
- case ".soap":
- return "application/soap+xml";
- case ".sql":
- return "application/sql";
- case ".xslt":
- return "application/xslt+xml";
- case ".zlib":
- return "application/zlib";
- case ".aac":
- return "audio/aac";
- case ".ac3":
- return "audio/ac3";
- case ".ogg":
- return "audio/ogg";
- case ".ttf":
- return "font/ttf";
- case ".bmp":
- return "image/bmp";
- case ".jpm":
- return "image/jpm";
- case ".jpx":
- return "image/jpx";
- case ".jrx":
- return "image/jrx";
- case ".tiff":
- return "image/tiff";
- case ".emf":
- return "image/emf";
- case ".wmf":
- return "image/wmf";
- case ".http":
- return "message/http";
- case ".s-http":
- return "message/s-http";
- case ".mesh":
- return "model/mesh";
- case ".vrml":
- return "model/vrml";
- case ".csv":
- return "text/csv";
- case ".plain":
- return "text/plain";
- case ".richtext":
- return "text/richtext";
- case ".rtf":
- return "text/rtf";
- case ".rtx":
- return "text/rtx";
- case ".sgml":
- return "text/sgml";
- case ".strings":
- return "text/strings";
- case ".url":
- return "text/uri-list";
- case ".H264":
- return "video/H264";
- case ".H265":
- return "video/H265";
- case ".mpeg":
- return "video/mpeg";
- case ".raw":
- return "video/raw";
- default:
- return "application/octet-stream";
- }
- }
- }
- }
|