1
0
mirror of https://github.com/sasjs/core.git synced 2025-12-10 14:04:36 +00:00
Files
core/server/mfs_httpheader.sas
2022-04-28 21:47:23 +01:00

54 lines
1.3 KiB
SAS

/**
@file
@brief Sets the http headers in the SASjs/server response
@details For GET requests, SASjs server will use the file generated by this
macro for setting the appropriate http headers in the response.
It works by writing a file to the session directory, that is then ingested by
the server.
The location of this file is driven by the global variable
`sasjs_stpsrv_header_loc` which is made available in the autoexec.
Usage:
%mfs_httpheader(Content-Type,application/csv)
@param [in] header_name Name of the http header to set
@param [in] header_value Value of the http header to set
<h4> Related Macros </h4>
@li mcf_stpsrv_header.sas
@version 9.3
@author Allan Bowe
**/
%macro mfs_httpheader(header_name
,header_value
)/*/STORE SOURCE*/;
%global sasjs_stpsrv_header_loc;
%local fref fid i;
%if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc)) ne 0 %then %do;
%put &=fref &=sasjs_stpsrv_header_loc;
%put %str(ERR)OR: %sysfunc(sysmsg());
%return;
%end;
%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(&header_name): %str(&header_value)));
%let rc=%sysfunc(fwrite(&fid));
%let rc=%sysfunc(fclose(&fid));
%let rc=%sysfunc(filename(&fref));
%mend mfs_httpheader;