zoukankan      html  css  js  c++  java
  • window7下karma 报 nodejs request TypeError: The header content contains invalid characters BUG

    这个BUG 估计只有中国人才 遇到

    打开你的依赖node_moduleskarma ode_modulesconnectlibpatch.js

    将里面的setHeader方法改成下面这样,干掉序列化日期时出现的中文

      res.setHeader = function(field, val){
        var key = field.toLowerCase()
          , prev;
    
        // special-case Set-Cookie
        if (key === 'set-cookie') {
          // detect code doing getHeader -> setHeader
          if (Array.isArray(val) && val.length > 1) {
            prev = [].concat(this.getHeader(field) || []);
            val = unique(prev, val);
          }
    
          return this.appendHeader(field, val);
        }
    
        // charset
        if ('content-type' == key && this.charset) {
          val = utils.setCharset(val, this.charset, true);
        }
        try{
            if(typeof  val === 'string'){
              val =  val.replace(/中国标准时间/,'')
            }
            return setHeader.call(this, field, val);
        }catch(e){
          console.log(e, val,field)
        }
      };
    
    
  • 相关阅读:
    EFCore
    PS-邮件发送异常信息
    python-Django
    Autofac
    swagger
    查看哪个程序占用了端口
    SQL SERVER-系统数据库还原
    破解root密码
    WebApi路由
    async,await.task
  • 原文地址:https://www.cnblogs.com/rubylouvre/p/6127190.html
Copyright © 2011-2022 走看看