Delphi HTTP/2 Client & Server — Multiplexed, Streaming, Push

A native Pascal implementation of RFC 9113 HTTP/2 — stream multiplexing, HPACK header compression, flow control, server push and the WebSocket-over-HTTP/2 extension (RFC 8441). Same component, client or server, from Delphi 7 to Delphi 13.

A pure-Pascal HTTP/2 stack

Not a thin wrapper around WinHTTP or libcurl — a from-scratch implementation that gives you frame-level control.

A Delphi HTTP/2 client is no longer optional: HTTP/2 is the wire format the entire modern web speaks. Apple Push Notifications require HTTP/2. Google APIs negotiate HTTP/2. AWS, Azure and CloudFront use HTTP/2 as the default. And the gains are real: a single TCP/TLS connection multiplexes dozens of in-flight requests, header sets are compressed with HPACK, and the server can push resources the client has not yet asked for. sgcWebSockets ships TsgcHTTP2Client (client) and HTTP/2 support inside TsgcWebSocketHTTPServer (server) — both pure Pascal, both running on every platform the Delphi compiler targets.

A Delphi HTTP/2 server in the same library can host REST APIs, push events to long-lived clients and accept WebSocket upgrades over HTTP/2 (RFC 8441) — the standard way modern infrastructure layers WebSocket on top of HTTP/2 / HTTP/3.

Client

TsgcHTTP2Client

Server

TsgcWebSocketHTTPServer with HTTP/2 enabled

Standards

RFC 9113 (HTTP/2), RFC 7541 (HPACK), RFC 8441 (WS-over-H2)

TLS

OpenSSL, SChannel, HTTP.sys — ALPN-negotiated

Why HTTP/2 matters

The four big wins over HTTP/1.1 — and the operational details that make them work.

Stream multiplexing

Up to SETTINGS_MAX_CONCURRENT_STREAMS in-flight requests over a single TCP+TLS connection — no head-of-line blocking, no connection pool to tune.

HPACK compression

Per-connection static + dynamic header table eliminates the kilobytes of repeated headers (cookies, user-agent, accept) that bloat HTTP/1.1 traffic.

Server push

Server can pre-emptively send resources the client will need (CSS, JS, JSON sub-resources) before the client requests them — cut a request round-trip.

Stream priorities

Per-stream weight and dependency tree let you tell the server to ship the index document before the analytics blob.

Flow control

Per-stream and per-connection WINDOW_UPDATE prevents a slow consumer from drowning the sender — back-pressure built into the wire format.

ALPN negotiation

TLS-layer ALPN negotiates h2 automatically — the client and server agree on HTTP/2 before the first request, with HTTP/1.1 fallback if the peer doesn’t speak it.

WebSocket-over-HTTP/2

RFC 8441: tunnel a WebSocket session inside one HTTP/2 stream — runs through every HTTP/2-aware load balancer (Envoy, nginx, ALB, GCLB).

Trailers & gRPC-friendly

HTTP trailers (per RFC 7230) are first-class — the foundation for gRPC’s status / message metadata.

Multiplexed GET requests

Fire 10 concurrent GETs on a single connection — HPACK and multiplexing make this routine.

uses
  sgcHTTP2_Client, sgcHTTP_Classes;

var
  HTTP2: TsgcHTTP2Client;
  i: Integer;
begin
  HTTP2 := TsgcHTTP2Client.Create(nil);
  HTTP2.Host := 'api.example.com';
  HTTP2.Port := 443;
  HTTP2.TLS  := True;
  HTTP2.TLSOptions.ALPNProtocols.Add('h2');
  HTTP2.OnResponse := DoResponse;

  HTTP2.Connect;

  // 10 concurrent GETs on ONE connection, ONE TLS handshake
  for i := 1 to 10 do
    HTTP2.Get(Format('/items/%d', [i]));
end;

procedure TForm1.DoResponse(Sender: TObject;
  const aStreamId: Cardinal;
  aHeaders: TsgcHTTP2Headers;
  aData: TBytes);
begin
  Memo1.Lines.Add(Format('stream %d  status %s  bytes %d',
    [aStreamId, aHeaders.Status, Length(aData)]));
end;

Push a sub-resource before the client asks

Inside an OnCommandGet handler, call PushPromise to pre-emptively send /style.css alongside /index.html.

uses
  sgcWebSocket, sgcHTTP_Classes;

procedure TForm1.WSServerCommandGet(Sender: TObject;
  aContext: TsgcWSConnection;
  ARequestInfo: TsgcWSRequestInfo;
  AResponseInfo: TsgcWSResponseInfo);
begin
  if ARequestInfo.URI = '/index.html' then
  begin
    // Push the CSS so the browser doesn’t round-trip for it
    AResponseInfo.PushPromise('/style.css');
    AResponseInfo.PushPromise('/app.js');

    AResponseInfo.ContentType := 'text/html; charset=utf-8';
    AResponseInfo.ContentText :=
      '<!doctype html><link rel="stylesheet" href="/style.css">' +
      '<script src="/app.js" defer></script>' +
      '<h1>HTTP/2 from Delphi</h1>';
  end;
end;

Where HTTP/2 is required, not optional

Apple Push Notifications

APNs only accepts HTTP/2 — one persistent connection, thousands of streams per second, JWT or certificate-based auth. See the Apple Push page.

Google FCM v1

The HTTP v1 FCM API runs on HTTP/2. See the Google FCM page.

gRPC services

gRPC is HTTP/2 with protobuf and trailers. The HTTP/2 stack here is the foundation a Pascal gRPC client builds on.

WebSocket-over-HTTP/2

The cleanest way to deploy WebSocket through modern load balancers and CDNs that prefer HTTP/2 upstream.

High-throughput REST clients

One connection, hundreds of in-flight requests — ideal for crawlers, market-data ingesters and fan-out workers.

Long-poll replacement

Stream a JSON-lines or SSE-style response over a single HTTP/2 stream — back-pressure included.

Deeper dives

HTTP/2 reference

Full component reference for the HTTP/2 client and server.

HTTP/2 client

Dedicated client component page.

HTTP/2 server

Dedicated server component page.

WebSocket component

WebSocket over HTTP/2 (RFC 8441) and over HTTP/1.1 (RFC 6455).

Blog: HTTP/2 initial server support

Original announcement and design notes.

Blog: HTTP/2 vs HTTP/1 performance

Benchmark numbers for multiplexing and HPACK gains.

Blog: HTTP/2 conformance tests

Running the h2spec suite against the server.

Blog: APNs over HTTP/2

Practical HTTP/2 example: APNs notifications.

Multiplex your requests today

Download the trial — both the HTTP/2 client and server demos compile out of the box.