CICS® stores
the request line used for each HTTP request, for the application program to
access if needed. An application program can use the WEB EXTRACT command to
extract components of the request URL (including the path, host name, port
number and query string), the method used for the request, or the HTTP version
of the request. Non-HTTP requests can also be identified in this way.
HTTP requests explains the items in a
request line. The request URL is a major element of the request line;
The components of a URL explains the
different parts of a URL. Your application program might need to examine any
of the items in the request line in order to process the request and provide
an appropriate response. Some common reasons for extracting information from
a request line are:
- Because the same application program is called to handle a number of different
requests, perhaps as part of a logical request sequence, or as different requests
that relate to the same resource.
- To see what action is being requested from the application by the HTTP
method. HTTP method reference for CICS Web support explains
the different methods that a Web client might use for a request, and suggests
action that is appropriate in each case.
- To use the path component of the URL. This identifies the resource to
which the request applies. As well as being used to map the request to the
handling application, the path component of the URL can be designed to provide
processing information to the application. For example, the path component
can be used to specify a particular function provided by the application.
Or if the Web-aware application is providing a front end for more than one
other application, the path component of the URL can identify the application
to which the request applies.URLs for CICS Web support explains
how this can be achieved.
- To obtain a query string for processing by the application.
- To identify the HTTP version for the Web client, so that the application
can provide an appropriate response. The HTTP version used by the Web client
can affect the HTTP headers, status code, and message content for the response.
HTTP/1.0 clients might not understand the more advanced features described
in the HTTP/1.1 specification.
- To identify a non-HTTP request. CICS Web support and non-HTTP requests has
more information about handling non-HTTP requests.
The
CICS Application
Programming Reference has full reference information and descriptions
of the options available on the
WEB EXTRACT command. The WEB EXTRACT command lets
you obtain the following items:
- Use the HOST option to obtain the host component of the request
URL, as specified either in the Host header field for the request, or in the
request line (if the absolute URI form was used for the request).
- Use the HTTPMETHOD option to obtain the HTTP method for the request
(for example, GET or PUT).
- Use the HTTPVERSION option to identify the HTTP version, HTTP/1.1
or HTTP/1.0.
- Use the PATH option to obtain the path component of the URL.
- Use the PORTNUMBER option to obtain the port number that applies
to the URL. Well-known port numbers for a service are normally
omitted from the URL. If the port number is not present in the URL, the WEB
EXTRACT command identifies and returns it based on the scheme. For HTTP, the
well-known port number is 80, and for HTTPS, the well-known port number is
443.
- Use the QUERYSTRING option to obtain the whole of the query string. The query string is returned in its escaped form, with %xx sequences
to represent certain characters that could hinder correct parsing. See Escaped and unescaped data for an explanation of this. Alternatively,
if the query string includes form data as name and value pairs (for example, account=40138025 ),
you can use the WEB READ FORMFIELD command to obtain this data in an unescaped
form. Examining form data in an HTTP request tells
you how to do this.
- Use the REQUESTYPE option to identify a non-HTTP request.