RXS_GetEnvVar()

This subprocedure is used to retrieve Apache server’s environment variables as well as some incoming HTTP headers. This is typically used in a scenario when you are hosting a web service.

  • AUTH_TYPE
  • CGI_ASCII_CCSID
  • CGI_EBCDIC_CCSID
  • CONTENT_LENGTH
  • CONTENT_TYPE
  • GATEWAY_INTERFACE
  • HTTP_ACCEPT
  • HTTP_USER_AGENT
  • PATH_INFO
  • PATH_TRANSLATED
  • QUERY_STRING
  • REMOTE_ADDR
  • REMOTE_HOST
  • REMOTE_IDENT
  • REQUEST_METHOD
  • REMOTE_USER
  • SCRIPT_NAME
  • SERVER_NAME
  • SERVER_PORT
  • SERVER_PROTOCOL
  • SERVER_SOFTWARE

This subprocedure can also be used to retrieve environment variables set with RXS_PutEnvVar().

Subprocedure Prototype

D RXS_GetEnvVar...
D                 PR                  Extproc('RXS_GetEnvVar') Opdesc
D                                     Like(RXS_Var16Mv_t)
D                                     Rtnparm

Returns the data retrieved from the environment variable.

D  pEnvVar                      30A   Value

Specify the name of the environment variable to retrieve the value of.

Example Code

*--------------------------------------------------------------
* This example code retrieves an environment variable. 
* The environment variable being retrieved, REQUEST_METHOD, would 
* be set by the Apache server, which means that it can only be 
* retrieved if this program is used as a web service.
*--------------------------------------------------------------
H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)

 /copy QRPGLECPY,RXSCB

D Data            S                   Like(RXS_Var1Kv_t)

 /free
  Data = RXS_GetEnvVar( 'REQUEST_METHOD' ); 
  RXS_JobLog( 'REQUEST METHOD? %s' : Data );
  *INLR = *ON;
 /end-free