E:\nodetest>node server.js_http_outgoing.js:360? ? throw new TypeError('The header content contains invalid characters');? ? ^TypeError: The header content contains invalid characters? ? at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:360:11)? ? at E:\nodetest\node_modules\express-static\index.js:48:11? ? at FSReqWrap.oncomplete (fs.js:123:15)這個(gè)錯(cuò)誤是什么原因?求大神指教源碼:const express=require('express');const static=require('express-static');const cookieParser=require('cookie-parser');const cookieSession=require('cookie-session');const bodyParser=require('body-parser');const multer=require('multer');const consolidate=require('consolidate');const mysql=require('mysql');//連接池const db=mysql.createPool({host: 'localhost', user: 'root', password: 'yue638', database: 'blog'});var server=express();server.listen(8080);//1.解析cookieserver.use(cookieParser('sdfasl43kjoifguokn4lkhoifo4k3'));//2.使用sessionvar arr=[];for(var i=0;i<100000;i++){? arr.push('keys_'+Math.random());}server.use(cookieSession({name: 'zns_sess_id', keys: arr, maxAge: 20*3600*1000}));//3.post數(shù)據(jù)server.use(bodyParser.urlencoded({extended: false}));server.use(multer({dest: './www/upload'}).any());//4.配置模板引擎//輸出什么東西server.set('view engine', 'html');//模板文件放在哪兒server.set('views', './template');//哪種模板引擎server.engine('html', consolidate.ejs);//接收用戶(hù)請(qǐng)求server.get('/', (req, res)=>{? //查詢(xún)banner的東西? db.query("SELECT * FROM banner_table", (err, data)=>{? ? if(err){? ? ? console.log(err);? ? ? res.status(500).send('database error').end();? ? }else{? ? ? console.log(data);? ? ? res.render('index.ejs', {banners: data});? ? }? });});//4.static數(shù)據(jù)server.use(static('./www'));
_http_outgoing.js:360 throw new TypeError('The header content contains invalid characters');
kathria
2017-07-19 09:36:40