Icon Server Request Architecture

Server Requests in Client Applications
Both visual and non-visual client applications are single-page web applications that are loaded in the web browser and stay loaded until the browser navigates to a different URL. Such an application is different from a traditional web site with a collection of individual web pages that are navigated using traditional URL links. Navigating to a different URL in aclient application will cause the application to be unloaded in the web browser, which is not the desired result for most situations.

Given this architecture, there needs to be a way for such an application to communicate with the web server in order to exchange data or content without causing an actual navigation or page load in the web browser. The name for this type of functionality in web browsers is called AJAX, which stands for "Asynchronous JavaScript and XML". The server request components wrap the AJAX functionality in the web browser for use with both visual and non-visual client applications.

All web server requests in client applications are asynchronous. This means that when a web server request is executed, the application will continue to execute and respond to user input while the request is being executed, and an event will be triggered when the request completes successfully or encounters an error.

Information While AJAX was originally designed to be used primarily with XML data (per the naming), it can be used with any type of textual content or data, as well as with HTML form data (including file uploads).

Server Requests in Server Applications
Server applications also provide very similar server request components for executing web server requests to other web servers. This is useful for functionality like accessing payment processor APIs and other types of APIs in ways that aren't permissible or feasible for the client applications to execute directly from a web browser.

All web server requests in server applications are synchronous. This means that the server application will wait until the request is completely executed before executing any subsequent code after the server request execution. This makes it easier to deal with control flow and the debugging of server requests in server applications.

Web server requests in server applications have some additional capabilities that aren't present in client applications, such as the ability to specify the user agent (required for some APIs), the ability to specify a connection timeout, the ability to use binary streams for request and response content, and the ability to easily set up server requests that are sending multi-part content to a web server.

Core Components
The components that encapsulate the web server request functionality are:

TServerRequest
TServerRequest components can be dropped directly on a form or request handler at design-time in a visual client project or server project, or created at run-time in a visual/non-visual client project or server project. The TServerRequest component encapsulates a single web server request. The Method property specifies the HTTP method (default rmGet) and the URL property specifies the URL for the request. Although the component will automatically populate all required request headers, you can specify additional request headers using the Headers property. The Execute method can be used to execute the request.

TServerRequestQueue
TServerRequestQueue components can be dropped directly on a form or request handler at design-time in a visual client project or server project, or created at run-time in a visual/non-visual client project or server project. The TServerRequestQueue component implements a queue of server requests in order to force serialization of the server requests so that requests are executed in the order in which they are added to the queue. For example, the TDatabase component uses an internal TServerRequestQueue component in client applications to ensure that both dataset load requests and transaction commit requests are executed in the order that they are requested.
Image