我正在尝试检索大量数据(使用1000+ORM从MongoDB中检索JugglingDB行)。如果我将限制设置为1001行,那么我的数据就完成了,但是一旦升到1002,数据就不完整了(如果我用cURL或浏览器点击它并不重要)。我不完全确定问题是什么,因为console.log显示了我所有的数据,但听起来好像我的响应头或响应本身有问题……下面是我试图使用的代码:
function getAllDevices(controller) {
controller.Device.all({limit: parseInt(controller.req.query.limit)}, function(err, devices) {
// This shows all of my devices, and the data is correct
console.log(devices, JSON.stringify(devices).length);
controller.req.headers['Accept-Encoding'] = '';
controller.res.setHeader('transfer-encoding', '');
controller.res.setHeader('Content-Length', JSON.stringify(devices).length);
return controller.send({success: true, data: devices});
});
}请求头
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Connection keep-alive
Host localhost响应头
Access-Control-Allow-Cred... true
Access-Control-Allow-Head... X-Requested-With,content-type
Access-Control-Allow-Meth... GET, POST, OPTIONS, PUT, PATCH, DELETE
Access-Control-Allow-Orig... *
Connection keep-alive
Content-Length 1610106
Content-Type application/json; charset=utf-8
Date Wed, 20 Aug 2014 17:20:51 GMT
Server nginx/1.6.0
X-Powered-By Express值得注意的是,我正在使用nginx作为Node服务器的反向代理,配置如下所示:
location /nodeJs/ {
proxy_pass http://127.0.0.1:3005/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection close;
proxy_pass_header Content-Type;
proxy_pass_header Content-Disposition;
proxy_pass_header Content-Length;
}发布于 2014-08-21 21:00:39
我想我已经解决了这个问题,再一次,它似乎是一种改变.在我的主nginx.conf文件中,我添加了:
gzip on;
gzip_types application/json;将应用程序/json添加到gzip_types是最终的解决方案。
https://stackoverflow.com/questions/25411168
复制相似问题