我在端口 8484 上运行 flash 套接字策略服务器。在同一端口上我需要接收 http 请求。我正在考虑检查是否请求了策略文件(在下面的 if 语句内),如果没有,则将 http 请求转发到正在运行 Express 的另一个端口(假设 localhost:3000)。我怎样才能得到它?
// flash socket policy server
var file = '/etc/flashpolicy.xml',
host = 'localhost',
port = 8484,
poli = 'something';
var fsps = require('net').createServer(function (stream) {
stream.setEncoding('utf8');
stream.setTimeout(10000);
stream.on('connect', function () {
console.log('Got connection from ' + stream.remoteAddress + '.');
});
stream.on('data', function (data) {
console.log(data);
var test = /^<policy-file-request\/>/;
if (test.test(data)) {
console.log('Good request. Sending file to ' + stream.remoteAddress + '.')
stream.end(poli + '\0');
} else …Run Code Online (Sandbox Code Playgroud)