Accessing client request information

When an HTTP request message is received by the Web server application, the headers of the client request are loaded into the properties of an object descended from TWebRequest. For example, in NSAPI and ISAPI applications, the request message is encapsulated by a TISAPIRequest object, and console CGI applications use TCGIRequest objects.

The properties of the request object are read-only. You can use them to gather all of the information available in the client request.

Properties that contain request header information

Most properties in a request object contain information about the request that comes from the HTTP request header. Not every request supplies a value for every one of these properties. Also, some requests may include header fields that are not surfaced in a property of the request object, especially as the HTTP standard continues to evolve. To obtain the value of a request header field that is not surfaced as one of the properties of the request object, use the GetFieldByName method.

Properties that identify the target

The full target of the request message is given by the URL property. Usually, this is a URL that can be broken down into the protocol (HTTP), Host (server system), ScriptName (server application), PathInfo (location on the host), and Query.

Each of these pieces is surfaced in its own property. The protocol is always HTTP, and the Host and ScriptName identify the Web server application. The dispatcher uses the PathInfo portion when matching action items to request messages. The Query is used by some requests to specify the details of the requested information. Its value is also parsed for you as the QueryFields property.

Properties that describe the Web client

The request also includes several properties that provide information about where the request originated. These include everything from the e-mail address of the sender (the From property), to the URI where the message originated (the Referer or RemoteHost property). If the request contains any content, and that content does not arise from the same URI as the request, the source of the content is given by the DerivedFrom property. You can also determine the IP address of the client (the RemoteAddr property), and the name and version of the application that sent the request (the UserAgent property).

Properties that identify the purpose of the request

The Method property is a string describing what the request message is asking the server application to do. The HTTP 1.1 standard defines the following methods:

Table 34.2 Predefined tag names


What the message requests


Information about available communication options.


Information identified by the URL property.


Header information from an equivalent GET message, without the content of the



The server application to post the data included in the Content property, as



The server application to replace the resource indicated by the URL property with the

data included in the Content property.


The server application to delete or hide the resource identified by the URL property.


The server application to send a loop-back to confirm receipt of the request.

The Method property may indicate any other method that the Web client requests of the server.

The Web server application does not need to provide a response for every possible value of Method. The HTTP standard does require that it service both GET and HEAD requests, however.

The MethodType property indicates whether the value of Method is GET (mtGet), HEAD (mtHead), POST (mtPost), PUT (mtPut) or some other string (mtAny). The dispatcher matches the value of the MethodType property with the MethodType of each action item.

Properties that describe the expected response

The Accept property indicates the media types the Web client will accept as the content of the response message. The IfModifiedSince property specifies whether the client only wants information that has changed recently. The Cookie property includes state information (usually added previously by your application) that can modify the response.

Properties that describe the content

Most requests do not include any content, as they are requests for information. However, some requests, such as POST requests, provide content that the Web server application is expected to use. The media type of the content is given in the ContentType property, and its length in the ContentLength property. If the content of the message was encoded (for example, for data compression), this information is in the ContentEncoding property. The name and version number of the application that produced the content is specified by the ContentVersion property. The Title property may also provide information about the content.

The content of HTTP request messages

In addition to the header fields, some request messages include a content portion that the Web server application should process in some way. For example, a POST request might include information that should be added to a database accessed by the Web server application.

The unprocessed value of the content is given by the Content property. If the content can be parsed into fields separated by ampersands (&), a parsed version is available in the ContentFields property.

Was this article helpful?

+1 0

Post a comment