Fixed the header handling
This commit is contained in:
15
server.js
15
server.js
@@ -31,7 +31,7 @@ http.createServer(function(req, res) {
|
||||
}
|
||||
} else {
|
||||
console.log("RCV-HTML");
|
||||
res.writeHead(200, { 'Content-Type': 'text/html', 'Cache-Control': 'no-cache' ,'Access-Control-Allow-Origin': '*' });
|
||||
//res.writeHead(200, { 'Content-Type': 'text/html', 'Cache-Control': 'no-cache' ,'Access-Control-Allow-Origin': '*' });
|
||||
arrMatches = req.url.match(new RegExp(/\/(save|raw)\/(.*)$/));
|
||||
console.log("Matches", arrMatches);
|
||||
if ((arrMatches) && (arrMatches.length === 3)) {
|
||||
@@ -100,18 +100,10 @@ http.createServer(function(req, res) {
|
||||
console.log("Full path " + filePath + " [" + contentType + "]" );
|
||||
|
||||
try {
|
||||
console.log("A");
|
||||
var stat = fs.statSync(filePath);
|
||||
|
||||
console.log("B");
|
||||
var readStream = fs.createReadStream(filePath);
|
||||
console.log("C");
|
||||
res.writeHead(200, {"Content-Type":contentType});
|
||||
|
||||
console.log("D");
|
||||
res.writeHead(200, { 'Content-Type': contentType, 'Cache-Control': 'no-cache' ,'Access-Control-Allow-Origin': '*' });
|
||||
readStream.pipe(res); // this will do a res.end() by its own.
|
||||
console.log("E");
|
||||
|
||||
} catch (ex) {
|
||||
res.writeHead(404,{"Content-Type":"text/html"});
|
||||
res.write("Not found: " + reqFile );
|
||||
@@ -130,7 +122,8 @@ function sendSSE(req, res) {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'text/event-stream',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Connection': 'keep-alive'
|
||||
'Connection': 'keep-alive',
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
});
|
||||
|
||||
var id = (new Date()).toLocaleTimeString();
|
||||
|
||||
Reference in New Issue
Block a user