From 4dcee4b3c3950d402220b8f451c50ad98a317d83 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Mon, 28 Nov 2022 23:53:36 +0500 Subject: [PATCH] fix: update the content type header after the program has been executed --- api/src/controllers/internal/Execution.ts | 9 +++++---- api/src/controllers/internal/Session.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/src/controllers/internal/Execution.ts b/api/src/controllers/internal/Execution.ts index fbe3b24..2ef6514 100644 --- a/api/src/controllers/internal/Execution.ts +++ b/api/src/controllers/internal/Execution.ts @@ -79,10 +79,6 @@ export class ExecutionController { const logPath = path.join(session.path, 'log.log') const headersPath = path.join(session.path, 'stpsrv_header.txt') - if (isDebugOn(vars)) { - await createFile(headersPath, 'content-type: text/plain') - } - const weboutPath = path.join(session.path, 'webout.txt') const tokenFile = path.join(session.path, 'reqHeaders.txt') @@ -110,6 +106,11 @@ export class ExecutionController { ? await readFile(headersPath) : '' const httpHeaders: HTTPHeaders = extractHeaders(headersContent) + + if (isDebugOn(vars)) { + httpHeaders['content-type'] = 'text/plain' + } + const fileResponse: boolean = httpHeaders.hasOwnProperty('content-type') const webout = (await fileExists(weboutPath)) diff --git a/api/src/controllers/internal/Session.ts b/api/src/controllers/internal/Session.ts index ccc08c6..032363b 100644 --- a/api/src/controllers/internal/Session.ts +++ b/api/src/controllers/internal/Session.ts @@ -94,7 +94,7 @@ export class SASSessionController extends SessionController { } const headersPath = path.join(session.path, 'stpsrv_header.txt') - await createFile(headersPath, 'content-type: text/html; charset=utf-8') + await createFile(headersPath, 'content-type: text/html; charset=utf-8\n') // we do not want to leave sessions running forever // we clean them up after a predefined period, if unused