相同的URL有时显示为红色,而其他时间显示为黑色。我看不出这两个请求之间的区别。有谁知道为什么?
我使用的版本是:
服务器端代码非常简单:
var http = require('http')
var _server = http.createServer();
var io = require('socket.io').listen(_server);
// QUESTION: I still get CORS errors although I have these allowed origins:
io.set('origins', "ws://localhost:* ws://127.0.0.1:* http://localhost:* http://127.0.0.1:*");
_server.listen(63143);
io.sockets.on('connection', function (socket) {
console.log("EventServer: connection");
socket.on('disconnect', function () {
console.log("EventServer: disconnect");
});
});
var url = require('url');
_server.on('request', function (req, res) {
console.log('EventServer: client request: ' + req.url);
res.writeHead(200, {"Content-Type": "text/html"});
//res.write('OK'); <========= QUESTION: this throws 'write after end' exception. Why?
res.end();
});