Skip to content

TWebHandler

Base class for handling HTTP requests in web applications

Declaration

Source position: custweb.pp line 44

type

  TWebHandler = class(TComponent)
  public
    constructor Create;
    destructor Destroy;
    procedure Run;
    procedure Log;
    procedure DoHandleRequest;
    procedure HandleRequest;
    property HandleGetOnPost: Boolean; {rw}
    property RedirectOnError: Boolean; {rw}
    property RedirectOnErrorURL: string; {rw}
    property ApplicationURL: string; {rw}
    property AllowDefaultModule: Boolean; {rw}
    property DefaultModuleName: string; {rw}
    property ModuleVariable: string; {rw}
    property OnGetModule: TGetModuleEvent; {rw}
    property Email: string; {rw}
    property Title: string; {rw}
    property Administrator: string; {rw}
    property OnShowRequestException: TOnShowRequestException; {rw}
    property OnIdle: TNotifyEvent; {rw}
    property OnLog: TLogEvent; {rw}
    property OnUnknownRequestEncoding: TOnUnknownEncodingEvent; {rw}
    property OnInitModule: TInitModuleEvent; {rw}
    property PreferModuleName: Boolean; {rw}
    property LegacyRouting: Boolean; {rw}
    property IncludeStackTraceInErrorPage: Boolean; {rwd}
  end;

Description

TWebHandler is the core component that handles HTTP requests in web applications. It provides the framework for routing requests to appropriate HTTP modules, handling errors, and managing the request-response cycle. This class serves as the foundation for all HTTP hosting implementations including CGI, FastCGI, HTTP server and Apache modules.

The handler supports both legacy routing and new HTTP routing systems, module lifecycle management, error handling with custom exception display, and event logging.

Properties

Member Visibility Description
Administrator public Administrator name for error pages
AllowDefaultModule public Controls whether requests without module names use default modules
ApplicationURL public Base URL for the web application
DefaultModuleName public Name of the default HTTP module for requests without explicit module names
Email public Administrator email address for error notifications
HandleGetOnPost public Controls whether GET requests are handled by POST handlers
IncludeStackTraceInErrorPage public
LegacyRouting public Controls whether to use legacy request routing instead of HTTP router
ModuleVariable public Query parameter name for specifying HTTP module names
PreferModuleName public Controls whether module name extraction is preferred over path info parsing
RedirectOnError public Controls whether errors trigger HTTP redirects
RedirectOnErrorURL public URL template for error redirects
Title public Application title displayed in error pages
See all Properties

Methods

Member Visibility Description
Create public Creates a new web handler instance
Destroy public Destroys the web handler instance
DoHandleRequest public Handles a complete HTTP request with error handling and cleanup
HandleRequest public Routes and processes an HTTP request to the appropriate handler
Log public Logs an event message using the configured log handler
Run public Main request processing loop for the web handler
See all Methods

Events

Member Visibility Description
OnGetModule public Event for custom module selection logic
OnIdle public Event triggered when the handler is idle between requests
OnInitModule public Event for initializing HTTP modules before request processing
OnLog public Event for logging web application events and errors
OnShowRequestException public Event for custom exception handling during request processing
OnUnknownRequestEncoding public Event for handling unknown request content encodings
See all Events

Errors

May raise HTTP-related exceptions during request processing.

See also

Name Description
TCustomWebApplication Base class for web applications with integrated request handling