Persistent connections are the default behaviour for CICS® Web support.
Before CICS TS 3.1, the connection behavior was that CICS would normally close the connection when data had been received from the Web client, unless the Web client sent a Connection: Keep-Alive header.
Now, when a connection is made between a Web client and CICS as an HTTP server, or between CICS as an HTTP client and a server, CICS attempts to keep the connection open by default.
With a TCPIPSERVICE resource definition for CICS Web support, the SOCKETCLOSE attribute of the TCPIPSERVICE definition should not be specified as zero. A zero setting for SOCKETCLOSE means that CICS as an HTTP server closes the connection immediately after receiving data from the Web client, unless further data is waiting. This means that persistent connections cannot be maintained.
If the application program needs to test whether the server has requested termination of the connection, the READ HTTPHEADER command can be used to look for the Connection: close header in the last message from the server. If the server requests closure of the connection, but the application program has not yet issued a WEB CLOSE command, CICS closes the connection but maintains the data relating to the connection (including the last response received from the server and its HTTP headers). The application program can continue to use that data until it issues a WEB CLOSE command or end of task is reached.
The WEB CLOSE command for CICS as an HTTP client does not cause CICS to notify the server that the persistent connection should be terminated. It only makes CICS close the connection. It is good behavior to include a Connection: close header on the final request that you make to the server. Using this header means that the server can close its persistent connection immediately after sending the final response, rather than waiting to see if CICS sends further requests and then timing out. To include this header, specify the CLOSESTATUS(CLOSE) option on the WEB SEND or WEB CONVERSE command.
If CICS as an HTTP client is communicating with an HTTP/1.0 server, CICS automatically sends Connection: Keep-Alive headers on HTTP messages. The application program that requested the connection does not need to provide these. Keep-Alive informs the server that a persistent connection is desired.