Skip to content

Feature/httpsys provider - #472

Merged
viniciussanchez merged 5 commits into
HashLoad:masterfrom
regyssilveira:feature/httpsys-provider
Jun 24, 2026
Merged

Feature/httpsys provider#472
viniciussanchez merged 5 commits into
HashLoad:masterfrom
regyssilveira:feature/httpsys-provider

Conversation

@regyssilveira

Copy link
Copy Markdown
Contributor

Description

This PR implements the native Windows HTTP.sys transport provider (Winapi.HttpApi) for the Horse framework, enabled via the compile-time conditional define HORSE_PROVIDER_HTTPSYS.

This provider runs HTTP parsing, connection pool management, and routing directly inside the Windows kernel-mode driver, providing superior performance, lower resource consumption (CPU/RAM), and native features such as port sharing and SSL/TLS management (via Schannel) with zero DLL dependencies.

Key Changes & Design Decisions

  1. Zero-Dependency Kernel Driver: Auto-contained integration with Winapi.HttpApi.pas nativelly supported on Delphi. No external DLLs (like OpenSSL) or libraries required.
  2. Core Preservation & Absolute Isolation:
    • The core framework classes were left untouched.
    • Instead of modifying the shared Horse.Provider.RawAdapters.pas (which contains empty write stubs for TInterfacedWebResponse), we inherited it locally as THttpSysWebResponse inside Horse.Provider.HttpSys.pas, implementing write properties (StatusCode, Content, ContentType) in isolation.
  3. Safe Memory & Lifecycle Management:
    • Adapted the requests and responses using Delphi Interfaces (IHorseRawRequest / IHorseRawResponse) to allow Delphi's Reference Counting to safely clean up memory and buffers, preventing double-free AVs and race conditions on multi-threaded environments.
    • Handled proper memory alignment ({$MINENUMSIZE 4}) for correct compatibility with httpapi.dll structures on x86/x64 platforms.
  4. Development Security (UAC Elevation Bypass):
    • Configured the provider to support localhost and 127.0.0.1 binds directly, which bypasses the Windows requirement for Administrator privileges during development.
  5. Tests & Samples:
    • tests/: Added a commented {.$DEFINE HORSE_PROVIDER_HTTPSYS} on API tests (Tests.Api.Console.pas and Tests.Api.Vcl.pas) so developers can easily toggle the test suite locally to run under HTTP.sys.
    • samples/: Added a fully working console application sample under samples/delphi/httpsys/ showcasing path parameters, query parameters, and native JSON response.

@viniciussanchez
viniciussanchez merged commit d83d7c6 into HashLoad:master Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants