1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-07 22:50:05 +00:00

fix(stp): return plain/text header for GET & debug

This commit is contained in:
Saad Jutt
2022-03-14 04:42:30 +05:00
parent 698180ab7e
commit 145ac45036
4 changed files with 23 additions and 7 deletions

View File

@@ -21,6 +21,7 @@ import { PreProgramVars } from '../types'
import {
getTmpFilesFolderPath,
HTTPHeaders,
isDebugOn,
LogLine,
makeFilesNamesMap,
parseLogToArray
@@ -62,7 +63,9 @@ export class STPController {
* The response headers can be adjusted using the mfs_httpheader() macro. Any
* file type can be returned, including binary files such as zip or xls.
*
* This behaviour differs for POST requests, in which case the reponse is
* If _debug is >= 131, response headers will contain Content-Type: 'text/plain'
*
* This behaviour differs for POST requests, in which case the response is
* always JSON.
*
* @summary Execute Stored Program, return raw _webout content.
@@ -140,6 +143,13 @@ const executeReturnRaw = async (
query
)) as ExecuteReturnRaw
// Should over-ride response header for
// debug on GET request to see entire log
// rendering on browser.
if (isDebugOn(query)) {
httpHeaders['content-type'] = 'text/plain'
}
req.res?.set(httpHeaders)
if (result instanceof Buffer) {