0

大量のデータ (JugglingDB ORM を使用して MongoDB から 1000 行以上) を取得しようとしています。制限を 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 を使用していることに注意してください。構成は次のようになります。

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;
}
4

1 に答える 1

0

私はこの問題を修正したと信じています。もう一度、nginx の変更のようです...メインのnginx.confファイルに次のように追加しました。

gzip on;
gzip_types application/json;

application/json を gzip_types に追加することが最終的な解決策です。

于 2014-08-21T21:00:39.910 に答える