1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-10 10:50:04 +00:00

fix: setting header in mp_abort for sasjs server

This commit is contained in:
Allan Bowe
2022-06-07 14:01:54 +00:00
parent abfe7fe339
commit 055e8d2f13
2 changed files with 34 additions and 12 deletions

23
all.sas
View File

@@ -2248,7 +2248,8 @@ Usage:
, mode=REGULAR , mode=REGULAR
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
%global sysprocessmode sysprocessname; %global sysprocessmode sysprocessname sasjs_stpsrv_header_loc;
%local fref fid i;
%if not(%eval(%unquote(&iftrue))) %then %return; %if not(%eval(%unquote(&iftrue))) %then %return;
@@ -2342,7 +2343,7 @@ Usage:
%end; %end;
%if %symexist(SYS_JES_JOB_URI) %then %do; %if %symexist(SYS_JES_JOB_URI) %then %do;
/* setup webout */ /* setup webout for Viya */
OPTIONS NOBOMFILE; OPTIONS NOBOMFILE;
%if "X&SYS_JES_JOB_URI.X"="XX" %then %do; %if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
filename _webout temp lrecl=999999 mod; filename _webout temp lrecl=999999 mod;
@@ -2352,6 +2353,18 @@ Usage:
name="_webout.json" lrecl=999999 mod; name="_webout.json" lrecl=999999 mod;
%end; %end;
%end; %end;
%else %if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc))=0 %then %do;
/* set up http header for SASjs Server */
%let fid=%sysfunc(fopen(&fref,A));
%if &fid=0 %then %do;
%put %str(ERR)OR: %sysfunc(sysmsg());
%return;
%end;
%let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
%let rc=%sysfunc(fwrite(&fid));
%let rc=%sysfunc(fclose(&fid));
%let rc=%sysfunc(filename(&fref));
%end;
/* send response in SASjs JSON format */ /* send response in SASjs JSON format */
data _null_; data _null_;
@@ -2372,9 +2385,7 @@ Usage:
msg=cats('"',msg,'"'); msg=cats('"',msg,'"');
if symexist('_debug') then debug=quote(trim(symget('_debug'))); if symexist('_debug') then debug=quote(trim(symget('_debug')));
else debug='""'; else debug='""';
if symexist('sasjsprocessmode') if symget('sasjsprocessmode')='Stored Program' then mode='SASJS';
and symget('sasjsprocessmode')='Stored Program'
then mode='SASJS';
if mode ne 'SASJS' then put '>>weboutBEGIN<<'; if mode ne 'SASJS' then put '>>weboutBEGIN<<';
put '{"SYSDATE" : "' "&SYSDATE" '"'; put '{"SYSDATE" : "' "&SYSDATE" '"';
put ',"SYSTIME" : "' "&SYSTIME" '"'; put ',"SYSTIME" : "' "&SYSTIME" '"';
@@ -2407,7 +2418,7 @@ Usage:
syswarningtext=quote(trim(symget('syswarningtext'))); syswarningtext=quote(trim(symget('syswarningtext')));
put ",""SYSWARNINGTEXT"" : " syswarningtext; put ",""SYSWARNINGTEXT"" : " syswarningtext;
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" '; put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
put "}" @; put "}" ;
if mode ne 'SASJS' then put '>>weboutEND<<'; if mode ne 'SASJS' then put '>>weboutEND<<';
run; run;

View File

@@ -63,7 +63,8 @@
, mode=REGULAR , mode=REGULAR
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
%global sysprocessmode sysprocessname; %global sysprocessmode sysprocessname sasjs_stpsrv_header_loc;
%local fref fid i;
%if not(%eval(%unquote(&iftrue))) %then %return; %if not(%eval(%unquote(&iftrue))) %then %return;
@@ -157,7 +158,7 @@
%end; %end;
%if %symexist(SYS_JES_JOB_URI) %then %do; %if %symexist(SYS_JES_JOB_URI) %then %do;
/* setup webout */ /* setup webout for Viya */
OPTIONS NOBOMFILE; OPTIONS NOBOMFILE;
%if "X&SYS_JES_JOB_URI.X"="XX" %then %do; %if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
filename _webout temp lrecl=999999 mod; filename _webout temp lrecl=999999 mod;
@@ -167,6 +168,18 @@
name="_webout.json" lrecl=999999 mod; name="_webout.json" lrecl=999999 mod;
%end; %end;
%end; %end;
%else %if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc))=0 %then %do;
/* set up http header for SASjs Server */
%let fid=%sysfunc(fopen(&fref,A));
%if &fid=0 %then %do;
%put %str(ERR)OR: %sysfunc(sysmsg());
%return;
%end;
%let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
%let rc=%sysfunc(fwrite(&fid));
%let rc=%sysfunc(fclose(&fid));
%let rc=%sysfunc(filename(&fref));
%end;
/* send response in SASjs JSON format */ /* send response in SASjs JSON format */
data _null_; data _null_;
@@ -187,9 +200,7 @@
msg=cats('"',msg,'"'); msg=cats('"',msg,'"');
if symexist('_debug') then debug=quote(trim(symget('_debug'))); if symexist('_debug') then debug=quote(trim(symget('_debug')));
else debug='""'; else debug='""';
if symexist('sasjsprocessmode') if symget('sasjsprocessmode')='Stored Program' then mode='SASJS';
and symget('sasjsprocessmode')='Stored Program'
then mode='SASJS';
if mode ne 'SASJS' then put '>>weboutBEGIN<<'; if mode ne 'SASJS' then put '>>weboutBEGIN<<';
put '{"SYSDATE" : "' "&SYSDATE" '"'; put '{"SYSDATE" : "' "&SYSDATE" '"';
put ',"SYSTIME" : "' "&SYSTIME" '"'; put ',"SYSTIME" : "' "&SYSTIME" '"';
@@ -222,7 +233,7 @@
syswarningtext=quote(trim(symget('syswarningtext'))); syswarningtext=quote(trim(symget('syswarningtext')));
put ",""SYSWARNINGTEXT"" : " syswarningtext; put ",""SYSWARNINGTEXT"" : " syswarningtext;
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" '; put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
put "}" @; put "}" ;
if mode ne 'SASJS' then put '>>weboutEND<<'; if mode ne 'SASJS' then put '>>weboutEND<<';
run; run;