From 112431a1b7461989c04100418d67d975a2a8f354 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Sun, 27 Nov 2022 21:57:26 +0500 Subject: [PATCH] fix: update the response header of request to stp/execute routes --- api/src/controllers/internal/Execution.ts | 5 +++++ api/src/controllers/internal/Session.ts | 4 ++-- api/src/controllers/stp.ts | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/src/controllers/internal/Execution.ts b/api/src/controllers/internal/Execution.ts index b7df0ab..fbe3b24 100644 --- a/api/src/controllers/internal/Execution.ts +++ b/api/src/controllers/internal/Execution.ts @@ -78,6 +78,11 @@ 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') diff --git a/api/src/controllers/internal/Session.ts b/api/src/controllers/internal/Session.ts index edcc6f5..bf46803 100644 --- a/api/src/controllers/internal/Session.ts +++ b/api/src/controllers/internal/Session.ts @@ -50,7 +50,7 @@ export class SessionController { } const headersPath = path.join(session.path, 'stpsrv_header.txt') - await createFile(headersPath, 'Content-type: text/plain') + await createFile(headersPath, 'content-type: text/html; charset=utf-8') this.sessions.push(session) return session @@ -94,7 +94,7 @@ export class SASSessionController extends SessionController { } const headersPath = path.join(session.path, 'stpsrv_header.txt') - await createFile(headersPath, 'Content-type: text/plain') + await createFile(headersPath, 'content-type: text/html; charset=utf-8') // we do not want to leave sessions running forever // we clean them up after a predefined period, if unused diff --git a/api/src/controllers/stp.ts b/api/src/controllers/stp.ts index 86120ec..b103688 100644 --- a/api/src/controllers/stp.ts +++ b/api/src/controllers/stp.ts @@ -91,6 +91,8 @@ const execute = async ( } ) + req.res?.header(httpHeaders) + if (result instanceof Buffer) { ;(req as any).sasHeaders = httpHeaders }