• Diocp HTTPServer 支持SVG


    Diocp是一个很强大,很稳定的服务端,但是里面的HTTPServer并不支持SVG文件,这里记录一下,以免以后忘记了

    diocp_ex_http_common.pas 单元的GetContentTypeFromFileExt函数,改为以下代码

    function GetContentTypeFromFileExt(const pvFileExt, pvDefault: string): String;
    var
      lvExt: String;
    begin
      lvExt := LowerCase(pvFileExt);
      ///新增对svg的支持
    {$REGION '支持svg文件'}
      if lvExt = '.svg' then
      begin
        Result := 'image/svg+xml';
      end else
    {$ENDREGION}
    
      if lvExt = '.js' then
      begin
        Result := 'application/javascript';
      end
      else if lvExt = '.css' then
      begin
        Result := 'text/css';
      end else if lvExt = '.apk' then
      begin
        Result := 'application/vnd.android.package-archive'
      end
      else if lvExt = '.json' then
      begin
        Result := 'application/json;charset=UTF-8';
      end
      else if (lvExt = '.html') or (lvExt = '.htm') then
      begin
        Result := 'text/html;charset=UTF-8';
      end
      else if (lvExt = '.jpg') or (lvExt = '.jpeg') then
      begin
        Result := 'image/jpeg';
      end
      else if (lvExt = '.gif') then
      begin
        Result := 'image/gif';
      end
      else if (lvExt = '.png') then
      begin
        Result := 'image/png';
      end else if CompareStrIgnoreCase(PChar(lvExt), '.m3u', -1) = 0 then
      begin
        Result := 'audio/mpegurl';
      end else if CompareStrIgnoreCase(PChar(lvExt), '.mp3', -1) = 0 then
      begin
        Result := 'audio/mp3';
      end else if CompareStrIgnoreCase(PChar(lvExt), '.mp4', -1) = 0 then
      begin
        Result := 'audio/mp4';
      end else if CompareStrIgnoreCase(PChar(lvExt), '.wma', -1) = 0 then
      begin
        Result := 'audio/wma';
      end else if CompareStrIgnoreCase(PChar(lvExt), '.wav', -1) = 0 then
      begin
        Result := 'audio/wav';
    
      end
      else
      begin
        Result := pvDefault;
      end;
    end;
    

      

  • 相关阅读:
    jQuery自定义选项卡插件
    jQuery委托事件delegate()方法
    发布/订阅模式
    Node.js + Nginx WNMP 多域名 多端口 反向代理
    让Nginx支持apk、ipa文件下载
    jQuery中bind方法传参
    Http协议详解
    vuecli2.X环境搭建
    vue绑定属性、绑定class及绑定style
    vue数据渲染、条件判断及列表循环
  • 原文地址:https://www.cnblogs.com/wuxi15/p/15800268.html
Copyright © 2020-2023  润新知