HTTP requests and response processing (as server)

Top  Previous  Next

HTTP requests for XCICS as an HTTP server are initiated by a Web client that makes a request to XCICS. XCICS provides the Web client with responses to the requests it makes. The responses can be created from a static document identified by a URIMAP resource definition, or they can be created dynamically by a user application program.

Processing for XCICS as an HTTP server takes place as follows:

1.XCICS receives a TCP/IP connection request. The XCICS Sockets domain uses the TCPIPSERVICE resource definition for the port to determine that the request should be processed by XCICS Web support. The TCPIPSERVICE definition specifies security attributes to be applied to the request, specifies the timeout setting for receiving the request message, and limits the maximum amount of data that can be received for a single request.
2.XCICS matches the URL for the request to a URIMAP definition, if available. XCICS tries to match the URL specified in the HTTP request to any URIMAP resource definitions that are related to the TCPIPSERVICE definition and apply to XCICS as an HTTP server. If a
successful match is made, the URIMAP definition tells XCICS how to process the request. If no match is found, XCICS continues with the default process, which begins at processing stage 5 with the analyzer program.
3.If the URIMAP definition specifies redirection, XCICS redirects the Web client to the specified URL. XCICS composes the redirection message and transmits it to the Web client. This completes the processing for that HTTP request.
4.If the URIMAP definition specifies a static response, XCICS forms and supplies the response. XCICS uses a document template or a UNIX/Linux/Windows file, together with appropriate HTTP headers, to form an HTTP response. The response undergoes appropriate code page conversion, and XCICS then transmits the response to the Web client. This completes the processing for that HTTP request.
5.An analyzer program may be run, if the URIMAP definition specifies its use, or if no matching URIMAP definition is found. The analyzer program can interpret the request dynamically, or it can be used for monitoring or audit purposes.
 
The analyzer program for the TCPIPSERVICE definition must be used in the request processing path if no URIMAP definition has been set up for the request. It might also be needed if you are using a non-Web-aware application program that has special requirements, for code page conversion or for pre-XCICS TS Version 3 compatibility processing. ("Analyzer programs" in topic 2.7 explains these situations.) Otherwise, the use of an analyzer program is optional, but note that the analyzer program is called to process the request if the URIMAP definition is not found.
 
If an analyzer program is being used, the HTTP request and the HTTP headers are passed to the analyzer program. The analyzer program can interpret the request to determine:
Which XCICS resources are to be used to service the request.
Which user ID is to be associated with the request.
Which of the remaining processing stages are required.
6.A converter program may be used to decode the request and construct input to the application program. Web-aware application programs should accept an HTTP request without any decoding. However, if you want to service an HTTP request using a non-Web aware application program that requires COMMAREA input, you can use a converter program to decode the request and construct input that fits the requirements of your application program. A converter program can be specified using a URIMAP definition, or it can be selected by an analyzer program.
7.An application program is executed to service the request. You can specify the application program using a URIMAP definition, or using an analyzer program. A Web-aware application program, using the EXEC CICS WEB and EXEC CICS DOCUMENT application programming interfaces, can be used to handle the request and construct a response. A non-Web-aware application program can be enabled for the Web using either a converter program (which translates the Web client's request into acceptable input, and composes an HTTP response based on the program's output), or a Web-aware application program that calls the non-Web aware program and uses its output.
 
The application program runs under an alias transaction.
 
The application program can perform the following tasks:
If the application program is Web-aware, it can examine the HTTP headers on the request, extract information (such as a query string) from the request line, receive the body of the request into a buffer for processing, select a status code and text for the status line of the response, and write HTTP headers for the response. EXEC XCICS WEB API commands such as WEB SEND and WEB WRITE HTTPHEADER are used to construct the response.
Whether or not the application is Web-aware, it can produce output that forms the body of the response. Web-aware application programs can produce an entity body formed from a XCICS document template or from a buffer of data. Application programs that are not Web-aware can produce output that can be converted by a Web-aware application program or a converter program into an entity body.
8.A converter program may be used to encode the output from the application program and construct an HTTP response. If the application program is not Web-aware and its output is not in the correct form to send to a Web client, you can use a converter program to produce an appropriate HTTP response including a status line and HTTP headers. The converter program can also perform other types of processing on the output, if desired.
 
The converter program can specify that processing stages 6 (decoding or other processing using converter program), 7 (application program) and 8 (encoding or other processing using converter program) should be repeated. Because the converter program can change the name of the application program, you can use this facility to allow more than one application program to work on the same request in sequence, and provide a single response.
9.If a request error or an abend occurs in the XCICS Web support process, an error response is sent to the Web client.
10.XCICS generates some required HTTP headers and adds them to the message. Appropriate headers are generated depending on the HTTP version for the response. If the response is HTTP/1.1, XCICS adds headers that are required for HTTP/1.1 messages. If the response is HTTP/1.0, XCICS adds the Connection: Keep-Alive header if the client has requested a persistent connection, and a small number of other headers. The values for some of these headers are generated directly by XCICS (such as the Date header), and the values of others are based on information provided by a Web-aware application program (using the WEB SEND command) or by a URIMAP definition. The headers can be added both to output from a Web-aware application, and to output from a converter program.
11.XCICS transmits the complete HTTP response to the Web client. If the Web client supports persistent connections, XCICS keeps the connection open for further possible HTTP requests, until the user application or Web client requests closure or the timeout period is reached.