When CICS® is
an HTTP client, the connection between CICS and the server can be terminated by
the server, or by CICS following a command issued by the application program,
or at end of task.
To manage connection closure effectively, the following behavior
is recommended:
- On the last request that you want to make to the server, specify
CLOSE for the CLOSESTATUS option on the WEB
SEND or WEB
CONVERSE command. CICS writes a Connection: close header
on the request, or, for a server at HTTP/1.0 level, omits the Connection:
Keep-Alive header. Specifying this option when you make your final request
is good behavior, because the information in the headers means that the server
can close its connection with you immediately after sending the final response,
rather than waiting to see if you send further requests before timing out.
The response from the server is still received and made available to your
application. However, you will not be able to send any further requests to
the server using this connection. Specifying the CLOSESTATUS option does not
have the same range of effects as issuing the WEB CLOSE command.
- If you need to test whether the server has requested termination
of the connection, use the WEB READ HTTPHEADER command to look for the Connection:
close header in the last message from the server. If the server
terminates the connection, the application program cannot send any further
requests using that connection, but it can receive responses that the server
sent before it terminated the connection.
- When all the HTTP requests and responses are completed, issue a WEB CLOSE command,
specifying the session token. When the connection is closed, the
session token that applies to it is no longer valid for use. The session token
is required to receive a response from the server and to read the HTTP headers
for the response, so the WEB CLOSE command should not be issued until you
have completed all interaction with the server and with the last response
that it sent. If the application program does not issue
a WEB CLOSE command, the connection is closed at end of task.