Listing Two
ReadPost: PROCEDURE; PARSE ARG StdinFile
/******************************************** */
/*Read HTML FORM POST input (if any) from */
/*standard input. Note that if the caller */
/*provides a filename then we save the input */
/*in case we need to send it to another */
/*script. If so we can restore the stdin for */
/*the called command by using the command: */
/*ADDRESS UNIX script '<' StdinF. */
/*A good way to get a unique filename to save */
/*the standard input in, is to use the process*/
/*id. For example: */
/* StdinFile='/tmp/stdin'_GETPID() */
/* Post=ReadPost(StdinFile) */
/*_GETPID() provides the process ID in UniREXX*/
/*ReadPost returns the POST input if the */
/*REQUEST_METHOD="POST" else it returns null. */
/*N.b. the returned Post input does NOT have */
/*plus signs (+) converted to spaces or hex */
/* ASCII %XX encodings converted to characters*/
/******************************************** */
In=''
IF GETENV('REQUEST_METHOD')="POST" THEN DO
In=CHARIN(,1,GETENV('CONTENT_LENGTH'))
IF In='' THEN DO
SAY '400: Null input from POST!'; EXIT
END
IF StdinFile/='' THEN DO
IF CHAROUT(StdinFile,In,1) /=0 THEN DO
SAY '500: Unable to write out all POST chars!'
EXIT
END
Fail=CHAROUT(StdinFile) /*Close the file*/
END
END
RETURN In