A CGI application can reference a "CGI environment variable" using the COBOL environment variable operation function while an ISAPI application cannot. Thus, the following three subroutines are used.
Get an HTTP header.
Get various information on a request.
Get authorization information.
A CGI application can set and reference Cookie data using the COBOL environment variable operation function while an ISAPI application cannot. Thus, the following special subroutines are used to handle Cookie data.
Register Cookie data.
Delete the existing Cookie data.
Initialize Cookie data to be sent to a client.
Get Cookie data included in a request.
For example, modify the processing that gets information from an HTTP header as follows:
Description in a CGI application
DISPLAY "HTTP_USER_AGENT" UPON environment-variable-name
ACCEPT browser-information FROM environment-variable-value
ON EXCEPTION
MOVE "Error" TO browser-information
END-ACCEPT.Modified description in an ISAPI application
MOVE "User-agent" TO COBW3-HEADER-NAME. CALL "COBW3_RECEIVE_HEADER" USING COBW3. IF COBW3-STATUS=ZERO THEN MOVE COBW3-HEADER-VALUE TO browser-information ELSE MOVE "Error" TO browser-information END-IF.
Modify the Cookie manipulation as follows:
Description in a CGI application
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY COBW3.
01 COOKIEDATA.
02 PIC X(19) VALUE "Sample+Cookie+data=".
02 COOKIEVALUE PIC X(32).
PROCEDURE DIVISION.
:
DISPLAY "HTTP_COOKIE" UPON environment-variable-name
ACCEPT COOKIEVALUE FROM environment-variable-value
ON EXCEPTION
MOVE "Error" TO COOKIEVALUE
END-ACCEPT.Modified description in an ISAPI application
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY COBW3.
01 COOKIEVALUE PIC X(32).
PROCEDURE DIVISION.
:
MOVE "Sample Cookie data" TO COBW3-COOKIE-NAME.
CALL "COBW3_GET_COOKIE" USING COBW3.
IF COBW3-STATUS=ZERO THEN
MOVE COBW3-COOKIE-VALUE TO COOKIEVALUE
ELSE
MOVE "Error" TO COOKIEVALUE
END-IF.To handle Cookie data through environment variable manipulation, the user needs to encode and decode URLs in the Cookie data. To work around this problem, use only alphanumeric characters in Cookie data.
Note that an en-size space, after URL encoding, becomes "+".