When
CICS®
is an HTTP client, the connection between
CICS
and
the server can be closed by the server, or by
CICS
following
a command issued by the application program.
If you
are using connection pooling, CICS keeps suitable connections in a
pool of dormant connections for reuse, instead of closing them.
About this task
By default, the connection between
CICS
and
the server is closed either at the server's request, or after
the application program has finished using it. However, if the
connection
was opened using a URIMAP resource that specified connection pooling,
and neither the server nor the application program have made a
request
to close the connection, CICS does not close the connection. Instead,
CICS checks that the connection is in a good state and then places
it in a pool of dormant connections. Pooled connections remain open
and can be reused by another application program or by another
instance
of the same application program to connect to the same server.
Procedure
-
While you are using the connection, if you want 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 closes the connection, the application program cannot
send any further requests using that connection, but it can receive
responses that the server sent before it closed the connection.
- Optional:
If you are not using connection pooling, 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 means that the server can close its
connection immediately after sending the final response, rather
than waiting for any further requests before timing out. Specifying
the CLOSESTATUS option does not have the same range of effects as
issuing the WEB CLOSE command.
Note: If you are using connection pooling, do not specify
CLOSE for the CLOSESTATUS option. Specifying CLOSESTATUS(CLOSE)
means that the server closes the connection and so it cannot be
placed in a pool.
-
When all the HTTP requests and responses are completed, issue a
WEB CLOSE
command, specifying the session token.
Issuing the WEB CLOSE command notifies CICS that the
application program has finished using the connection. When you
issue the command, the session token that applies to this use of
the connection 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 do not issue the WEB CLOSE command
until you have completed all interaction with the server and with
the last response that it sent.
- If the connection is still open when you issue the WEB CLOSE command,
and it was opened using a URIMAP resource that specified connection
pooling, CICS does not close
the connection. CICS checks
the state of the connection and places it in a pool for reuse.
- If the connection is not suitable for connection pooling when
you issue the WEB CLOSE command, because the server or your application
program has previously made a request to close the connection, or
it was not opened using a suitable URIMAP resource, or it is not in
a good state, CICS closes the
connection and does not place it in a pool.
- If you do not issue the WEB CLOSE command, CICS closes the connection at end of task. The
closed connection cannot be placed in a pool. To enable connection
pooling, your application must issue the WEB CLOSE command.