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