From fdd566e8ce1eedc948f785c9e2c134200054dc28 Mon Sep 17 00:00:00 2001 From: Allan Bowe Date: Sat, 1 May 2021 16:27:41 +0300 Subject: [PATCH] fix: setting server headers only if STREAM mode enabled to avoid 'Function is only valid for filerefs using the CACHE access method.' error when testing STPs from Studio. Also removing proc json as it cannot handle invalid characters. --- all.sas | 46 +++++++++++++++++++----------------- meta/mm_createwebservice.sas | 23 +++++++++--------- meta/mm_webout.sas | 23 +++++++++--------- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/all.sas b/all.sas index 38ef21b..2c49690 100644 --- a/all.sas +++ b/all.sas @@ -7675,8 +7675,16 @@ data _null_; put '%else %if &action=OPEN %then %do; '; put ' /* fix encoding */ '; put ' OPTIONS NOBOMFILE; '; + put ' '; + put ' /** '; + put ' * check engine type to avoid the below err message: '; + put ' * > Function is only valid for filerefs using the CACHE access method. '; + put ' */ '; put ' data _null_; '; - put ' rc = stpsrv_header(''Content-type'',"text/html; encoding=utf-8"); '; + put ' set sashelp.vextfl(where=(fileref="_WEBOUT")); '; + put ' if xengine=''STREAM'' then do; '; + put ' rc=stpsrv_header(''Content-type'',"text/html; encoding=utf-8"); '; + put ' end; '; put ' run; '; put ' '; put ' /* setup json */ '; @@ -7690,16 +7698,9 @@ data _null_; put '%end; '; put ' '; put '%else %if &action=ARR or &action=OBJ %then %do; '; - put ' %if &sysver=9.4 %then %do; '; - put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt '; - put ' ,engine=PROCJSON,dbg=%str(&_debug) '; - put ' ) '; - put ' %end; '; - put ' %else %do; '; - put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt '; - put ' ,engine=DATASTEP,dbg=%str(&_debug) '; - put ' ) '; - put ' %end; '; + put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt '; + put ' ,engine=DATASTEP,dbg=%str(&_debug) '; + put ' ) '; put '%end; '; put '%else %if &action=CLOSE %then %do; '; put ' %if %str(&_debug) ge 131 %then %do; '; @@ -11144,8 +11145,16 @@ run; %else %if &action=OPEN %then %do; /* fix encoding */ OPTIONS NOBOMFILE; + + /** + * check engine type to avoid the below err message: + * > Function is only valid for filerefs using the CACHE access method. + */ data _null_; - rc = stpsrv_header('Content-type',"text/html; encoding=utf-8"); + set sashelp.vextfl(where=(fileref="_WEBOUT")); + if xengine='STREAM' then do; + rc=stpsrv_header('Content-type',"text/html; encoding=utf-8"); + end; run; /* setup json */ @@ -11159,16 +11168,9 @@ run; %end; %else %if &action=ARR or &action=OBJ %then %do; - %if &sysver=9.4 %then %do; - %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt - ,engine=PROCJSON,dbg=%str(&_debug) - ) - %end; - %else %do; - %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt - ,engine=DATASTEP,dbg=%str(&_debug) - ) - %end; + %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt + ,engine=DATASTEP,dbg=%str(&_debug) + ) %end; %else %if &action=CLOSE %then %do; %if %str(&_debug) ge 131 %then %do; diff --git a/meta/mm_createwebservice.sas b/meta/mm_createwebservice.sas index 858ae4b..9bdfb39 100644 --- a/meta/mm_createwebservice.sas +++ b/meta/mm_createwebservice.sas @@ -237,8 +237,16 @@ data _null_; put '%else %if &action=OPEN %then %do; '; put ' /* fix encoding */ '; put ' OPTIONS NOBOMFILE; '; + put ' '; + put ' /** '; + put ' * check engine type to avoid the below err message: '; + put ' * > Function is only valid for filerefs using the CACHE access method. '; + put ' */ '; put ' data _null_; '; - put ' rc = stpsrv_header(''Content-type'',"text/html; encoding=utf-8"); '; + put ' set sashelp.vextfl(where=(fileref="_WEBOUT")); '; + put ' if xengine=''STREAM'' then do; '; + put ' rc=stpsrv_header(''Content-type'',"text/html; encoding=utf-8"); '; + put ' end; '; put ' run; '; put ' '; put ' /* setup json */ '; @@ -252,16 +260,9 @@ data _null_; put '%end; '; put ' '; put '%else %if &action=ARR or &action=OBJ %then %do; '; - put ' %if &sysver=9.4 %then %do; '; - put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt '; - put ' ,engine=PROCJSON,dbg=%str(&_debug) '; - put ' ) '; - put ' %end; '; - put ' %else %do; '; - put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt '; - put ' ,engine=DATASTEP,dbg=%str(&_debug) '; - put ' ) '; - put ' %end; '; + put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt '; + put ' ,engine=DATASTEP,dbg=%str(&_debug) '; + put ' ) '; put '%end; '; put '%else %if &action=CLOSE %then %do; '; put ' %if %str(&_debug) ge 131 %then %do; '; diff --git a/meta/mm_webout.sas b/meta/mm_webout.sas index 8c71e09..a108803 100644 --- a/meta/mm_webout.sas +++ b/meta/mm_webout.sas @@ -68,8 +68,16 @@ %else %if &action=OPEN %then %do; /* fix encoding */ OPTIONS NOBOMFILE; + + /** + * check engine type to avoid the below err message: + * > Function is only valid for filerefs using the CACHE access method. + */ data _null_; - rc = stpsrv_header('Content-type',"text/html; encoding=utf-8"); + set sashelp.vextfl(where=(fileref="_WEBOUT")); + if xengine='STREAM' then do; + rc=stpsrv_header('Content-type',"text/html; encoding=utf-8"); + end; run; /* setup json */ @@ -83,16 +91,9 @@ %end; %else %if &action=ARR or &action=OBJ %then %do; - %if &sysver=9.4 %then %do; - %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt - ,engine=PROCJSON,dbg=%str(&_debug) - ) - %end; - %else %do; - %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt - ,engine=DATASTEP,dbg=%str(&_debug) - ) - %end; + %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt + ,engine=DATASTEP,dbg=%str(&_debug) + ) %end; %else %if &action=CLOSE %then %do; %if %str(&_debug) ge 131 %then %do;