RAD Studio
ContentsIndex
PreviousUpNext
Accessing client request information
Name 
Description 
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, including  
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.
The request header properties can be categorized by function:
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 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. 
The request 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). 
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:
Predefined tag names  
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... more 
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. 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!