@sasjs/core 4.8.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/mfs_httpheader.sas +52 -0
package/package.json
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Sets the http headers in the SASjs/server response
|
|
4
|
+
@details For GET requests, SASjs server will use the file generated by this
|
|
5
|
+
macro for setting the appropriate http headers in the response.
|
|
6
|
+
|
|
7
|
+
It works by writing a file to the session directory, that is then ingested by
|
|
8
|
+
the server.
|
|
9
|
+
|
|
10
|
+
The location of this file is driven by the global variable
|
|
11
|
+
`sasjs_stpsrv_header_loc` which is made available in the autoexec.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
|
|
15
|
+
%mfs_httpheader(Content-type,application/csv)
|
|
16
|
+
|
|
17
|
+
@param [in] header_name Name of the http header to set
|
|
18
|
+
@param [in] header_value Value of the http header to set
|
|
19
|
+
|
|
20
|
+
<h4> Related Macros </h4>
|
|
21
|
+
@li mcf_stpsrv_header.sas
|
|
22
|
+
|
|
23
|
+
@version 9.3
|
|
24
|
+
@author Allan Bowe
|
|
25
|
+
|
|
26
|
+
**/
|
|
27
|
+
|
|
28
|
+
%macro mfs_httpheader(header_name
|
|
29
|
+
,header_value
|
|
30
|
+
)/*/STORE SOURCE*/;
|
|
31
|
+
%local fref fid i;
|
|
32
|
+
|
|
33
|
+
%if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc)) ne 0 %then %do;
|
|
34
|
+
%put &=fref &=sasjs_stpsrv_header_loc;
|
|
35
|
+
%put %str(ERR)OR: %sysfunc(sysmsg());
|
|
36
|
+
%return;
|
|
37
|
+
%end;
|
|
38
|
+
|
|
39
|
+
%let fid=%sysfunc(fopen(&fref,A));
|
|
40
|
+
|
|
41
|
+
%if &fid=0 %then %do;
|
|
42
|
+
%put %str(ERR)OR: %sysfunc(sysmsg());
|
|
43
|
+
%return;
|
|
44
|
+
%end;
|
|
45
|
+
|
|
46
|
+
%let rc=%sysfunc(fput(&fid,%str(&header_name): %str(&header_value)));
|
|
47
|
+
%let rc=%sysfunc(fwrite(&fid));
|
|
48
|
+
|
|
49
|
+
%let rc=%sysfunc(fclose(&fid));
|
|
50
|
+
%let rc=%sysfunc(filename(&fref));
|
|
51
|
+
|
|
52
|
+
%mend mfs_httpheader;
|