【发布时间】:2011-10-26 22:04:35
【问题描述】:
Node 的 HTTP 模块未从该 URL 返回所有预期数据:http://itradedata.co.za/pmchart/prices/GetPricesTRI.asp?Shortname=ACE&numprices=5
在浏览器中查看时有 5 条价格记录,但在 Node 的 HTTP GET 数据中只有一条。数据包嗅探显示所有进入的数据,为什么它没有在输出中?
var http = require('http'),
host = 'itradedata.co.za',
records = 5,
url = '/pmchart/prices/GetPricesTRI.asp?Shortname=ACE&numprices=' + records,
client = http.createClient(80, host),
headers = { 'host': host },
req;
req = client.request('GET', url, headers);
req.on('response', function(res) {
console.log(res.statusCode);
res.on('data', function (chunk) {
console.log(chunk.toString());
});
});
req.end();
问题似乎在于服务器返回数据的方式... cURL 在终端中运行curl {url} 时也不显示数据,但在使用@987654324 时它会将所有内容写入文件@。这是怎么回事?
预期结果:
# Attempting to get 5 prices for theTicker: ACE<BR>
# Trying JSECODE<BR>
# Sending prices for Entity_ID: 17352 Shortname: ShareID: JSECode: <BR>
2011-8-15,46,46,46,46,0,08268
2011-8-12,46,46,46,46,51,0068
2011-8-11,46,46,46,46,51,0068
2011-8-10,46,46,46,46,51,0068
2011-8-8,46,46,46,46,51,00068
实际结果:
# Attempting to get 5 prices for theTicker: ACE<BR>
# Trying JSECODE<BR>
# Sending prices for Entity_ID: 17352 Shortname: ShareID: JSECode: <BR>
2011-8-8,46,46,46,46,51,00068
四个缺失的记录在结果的中间。
【问题讨论】: