diff --git a/api/src/controllers/internal/Execution.ts b/api/src/controllers/internal/Execution.ts index 1beb046..b5594a6 100644 --- a/api/src/controllers/internal/Execution.ts +++ b/api/src/controllers/internal/Execution.ts @@ -89,6 +89,8 @@ export class ExecutionController { tokenFile, preProgramVariables?.httpHeaders.join('\n') ?? '' ) + if (returnJson) + await createFile(headersPath, 'Content-type: application/json') await processProgram( program, @@ -96,6 +98,7 @@ export class ExecutionController { vars, session, weboutPath, + headersPath, tokenFile, runTime, logPath, diff --git a/api/src/controllers/internal/createJSProgram.ts b/api/src/controllers/internal/createJSProgram.ts index c669ac5..5738a82 100644 --- a/api/src/controllers/internal/createJSProgram.ts +++ b/api/src/controllers/internal/createJSProgram.ts @@ -9,6 +9,7 @@ export const createJSProgram = async ( vars: ExecutionVars, session: Session, weboutPath: string, + headersPath: string, tokenFile: string, otherArgs?: any ) => { @@ -23,15 +24,16 @@ let _webout = ''; const weboutPath = '${ isWindows() ? weboutPath.replace(/\\/g, '\\\\') : weboutPath }'; -const _sasjs_tokenfile = '${ +const _SASJS_TOKENFILE = '${ isWindows() ? tokenFile.replace(/\\/g, '\\\\') : tokenFile }'; -const _sasjs_username = '${preProgramVariables?.username}'; -const _sasjs_userid = '${preProgramVariables?.userId}'; -const _sasjs_displayname = '${preProgramVariables?.displayName}'; -const _metaperson = _sasjs_displayname; -const _metauser = _sasjs_username; -const sasjsprocessmode = 'Stored Program'; +const _SASJS_WEBOUT_HEADERS = '${headersPath}'; +const _SASJS_USERNAME = '${preProgramVariables?.username}'; +const _SASJS_USERID = '${preProgramVariables?.userId}'; +const _SASJS_DISPLAYNAME = '${preProgramVariables?.displayName}'; +const _METAPERSON = _SASJS_DISPLAYNAME; +const _METAUSER = _SASJS_USERNAME; +const SASJSPROCESSMODE = 'Stored Program'; ` const requiredModules = `const fs = require('fs')` diff --git a/api/src/controllers/internal/createPythonProgram.ts b/api/src/controllers/internal/createPythonProgram.ts index 497ab27..892ed14 100644 --- a/api/src/controllers/internal/createPythonProgram.ts +++ b/api/src/controllers/internal/createPythonProgram.ts @@ -9,6 +9,7 @@ export const createPythonProgram = async ( vars: ExecutionVars, session: Session, weboutPath: string, + headersPath: string, tokenFile: string, otherArgs?: any ) => { @@ -22,6 +23,7 @@ _SASJS_SESSION_PATH = '${ isWindows() ? session.path.replace(/\\/g, '\\\\') : session.path }'; _WEBOUT = '${isWindows() ? weboutPath.replace(/\\/g, '\\\\') : weboutPath}'; +_SASJS_WEBOUT_HEADERS = '${headersPath}'; _SASJS_TOKENFILE = '${ isWindows() ? tokenFile.replace(/\\/g, '\\\\') : tokenFile }'; diff --git a/api/src/controllers/internal/processProgram.ts b/api/src/controllers/internal/processProgram.ts index 9f541c7..db2db10 100644 --- a/api/src/controllers/internal/processProgram.ts +++ b/api/src/controllers/internal/processProgram.ts @@ -18,6 +18,7 @@ export const processProgram = async ( vars: ExecutionVars, session: Session, weboutPath: string, + headersPath: string, tokenFile: string, runTime: RunTimeType, logPath: string, @@ -30,6 +31,7 @@ export const processProgram = async ( vars, session, weboutPath, + headersPath, tokenFile, otherArgs ) @@ -66,6 +68,7 @@ export const processProgram = async ( vars, session, weboutPath, + headersPath, tokenFile, otherArgs ) diff --git a/api/src/routes/api/spec/stp.spec.ts b/api/src/routes/api/spec/stp.spec.ts index 9b05b98..7304a4f 100644 --- a/api/src/routes/api/spec/stp.spec.ts +++ b/api/src/routes/api/spec/stp.spec.ts @@ -450,6 +450,7 @@ const makeRequestAndAssert = async ( expect.anything(), expect.anything(), expect.anything(), + expect.anything(), expectedRuntime, expect.anything(), undefined