HTTP/2 Protocol

Native HTTP/2 client and server for Delphi and C++Builder. Binary framing, stream multiplexing, HPACK header compression and ALPN negotiation — no IIS, Apache or Indy dependency.

Pick the side you need

Two production-ready components implement the full HTTP/2 (RFC 9113) wire protocol. Use the client to consume HTTP/2 APIs, use the server to publish them — or both inside the same application.

TsgcHTTP2Client

Native HTTP/2 client — multiplexed GET/POST/PUT/DELETE over a single TLS connection, HPACK-compressed headers, ALPN h2 upgrade or prior-knowledge h2c, server-push handling and bearer / basic / NTLM authentication.

Open HTTP/2 Client →

TsgcWebSocketHTTPServer

Native HTTP/2 server — the same WebSocket HTTP server serves HTTP/1.1, HTTP/2 (h2) and WebSocket on one TLS port. ALPN negotiation, stream multiplexing, HPACK responses and optional RFC 8441 WebSocket-over-HTTP/2 bootstrap.

Open HTTP/2 Server →

HTTP/2 in sgcWebSockets

A first-class implementation of HTTP/2 framing wired into both the client and the WebSocket HTTP server.

Components

TsgcHTTP2Client
TsgcWebSocketHTTPServer

Platforms

Windows, macOS, Linux, iOS, Android

Editions

Client: Standard / Pro / Enterprise
Server: Pro / Enterprise

What HTTP/2 brings

All the wins of HTTP/2 over HTTP/1.1 — in native Delphi/C++Builder code, without spawning a separate web server.

Binary framing

Requests and responses are split into binary frames, parsed by a deterministic state machine. No more text-line parsing or HTTP/1.1 ambiguity.

Stream multiplexing

Dozens of in-flight requests share a single TCP/TLS connection — no head-of-line blocking at the HTTP layer, no extra sockets per request.

HPACK header compression

Built-in HPACK encoder/decoder (RFC 7541). Repeated cookies, auth tokens and content-type headers cost almost zero bytes after the first request.

ALPN negotiation

During the TLS handshake the peer advertises h2 and http/1.1; the negotiated ALPN value selects the protocol with no round-trips wasted.

Prior-knowledge h2c

For trusted internal links and service-mesh sidecars, both sides can skip ALPN and start HTTP/2 over plaintext via HTTP2_PriorKnowledge.

Server push

The server may proactively send PUSH_PROMISE responses; the client surfaces them through OnHTTP2StreamData for caching. Note: deprecated on the public web, still useful internally.

Stream prioritization

Per-stream priority and dependency hints let critical responses (auth, navigation, JSON-RPC results) overtake bulk transfers on the same connection.

Flow control

Per-stream and per-connection WINDOW_UPDATE flow control prevents one large response from starving smaller ones — tunable through SETTINGS frames.

TLS via OpenSSL or SChannel

Set TLSOptions.IOHandler to iohSChannel for Windows kernel TLS (no DLLs) or iohOpenSSL for full cross-platform 1.2/1.3 support.

Where HTTP/2 shines

Drop-in scenarios where the multiplexing and HPACK savings of HTTP/2 pay for themselves immediately.

Apple Push Notifications

Apple's APNs provider API requires HTTP/2. TsgcHTTP2Client drives the Apple Push component end-to-end with token-based auth.

Firebase Cloud Messaging

Google's FCM HTTP v1 API runs over HTTP/2. Same component powers FCM with service-account JWT minting.

Modern REST & JSON APIs

Most cloud APIs (Stripe, GitHub, Cloudflare, Google, Azure…) speak HTTP/2 by default — multiplexed clients cut latency on parallel calls.

Service-to-service traffic

Internal microservices behind a sidecar mesh use HTTP/2 prior-knowledge (h2c) to multiplex hundreds of RPC streams over one socket.

WebSocket + HTTP/2 on one port

TsgcWebSocketHTTPServer serves HTTP/1.1, HTTP/2 and WebSocket on a single TLS endpoint — ALPN routes each connection automatically.

RFC 8441 WebSocket over HTTP/2

For clients that prefer to tunnel WebSocket frames inside HTTP/2 streams, enable Specifications.RFC8441 on the server.

Client & server in a few lines

Drop the component, set TLS, go. ALPN negotiates h2 for you during the handshake.

uses
  sgcHTTP, sgcHTTP2;

var
  HTTP2: TsgcHTTP2Client;
begin
  HTTP2 := TsgcHTTP2Client.Create(nil);
  HTTP2.TLSOptions.IOHandler := iohSChannel; // or iohOpenSSL
  HTTP2.TLSOptions.Version   := tls1_2;

  // Add custom headers (compressed by HPACK)
  HTTP2.Request.CustomHeaders.Add('authorization: Bearer eyJ...');

  // GET over HTTP/2 (ALPN negotiates h2)
  Memo1.Text := HTTP2.Get('https://api.example.com/v1/items');
  ShowMessage(IntToStr(HTTP2.Response.Status));
end;
uses
  sgcWebSocket;

var
  Server: TsgcWebSocketHTTPServer;
begin
  Server := TsgcWebSocketHTTPServer.Create(nil);
  Server.Port := 443;
  Server.SSL  := True;
  Server.SSLOptions.CertFile := 'cert.pem';
  Server.SSLOptions.KeyFile  := 'key.pem';

  // HTTP/1.1, HTTP/2 and WebSocket on the same TLS port
  Server.Specifications.HTTP    := True;
  Server.Specifications.HTTP2   := True;
  Server.Specifications.RFC6455 := True;

  Server.Active := True;
end;
// uses: sgcHTTP, sgcHTTP2
TsgcHTTP2Client *HTTP2 = new TsgcHTTP2Client(this);
HTTP2->TLSOptions->IOHandler = iohSChannel;
HTTP2->Request->CustomHeaders->Add("authorization: Bearer eyJ...");
Memo1->Text = HTTP2->Get("https://api.example.com/v1/items");

Specifications & references

Authoritative sources for the protocols these components implement.

Documentation & Demos

Deep-link to the component pages, online help and the ready-to-run demo project shipped inside the trial.

HTTP/2 Client — TsgcHTTP2Client Component page: features, code samples and TLS options for the client.
HTTP/2 Server — TsgcWebSocketHTTPServer Component page: how to enable HTTP/2 alongside HTTP/1.1 and WebSocket on one TLS port.
Online Help — HTTP/2 Full property, method and event reference for HTTP/2 components.
Demo Project — Demos\20.HTTP_Protocol\01.HTTP2_Server_And_Client Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.
User Manual (PDF) Comprehensive manual covering every component in the library.

Ready to Use HTTP/2?

Download the free trial and add multiplexed HTTP/2 client and server traffic to your Delphi applications.