Examining the request line for an HTTP request

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.

About this task

For information about the items in a request line, see The HTTP protocol . 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 examine any of the items in the request line so that it can process the request and provide an appropriate response. Here are some common reasons for extracting information from a request line:
  • To ensure that 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, which identifies the resource to which the request applies. In addition to being used to map the request to the handling application, you can design the path component of the URL to provide processing information to the application. For example, the path component can 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 handle 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.
See WEB EXTRACT full reference information about the options. Use the WEB EXTRACT command to obtain the following items:

Procedure

  • 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 typically 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 might prevent correct parsing. See Reserved and excluded characters for an explanation.
    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 use the command.
  • Use the REQUESTYPE option to identify a non-HTTP request.