HTTP/2 Server

Serve HTTP/2 (h2) alongside HTTP/1.1 and WebSocket on a single TLS port via TsgcWebSocketHTTPServer. ALPN negotiation, HPACK and stream multiplexing are integriert.

TsgcWebSocketHTTPServer

The same TsgcWebSocketHTTPServer used for WebSocket and HTTP/1.1 also serves HTTP/2 over TLS — toggle Specifications.HTTP2, ALPN handles the rest.

Komponentenklasse

TsgcWebSocketHTTPServer

Protokoll

HTTP/2 (RFC 9113)

Plattformen

Windows, macOS, Linux, iOS, Android

Edition

Professional / Enterprise

Enable HTTP/2 with one property

On a TsgcWebSocketHTTPServer instance, enable TLS and toggle Specifications.HTTP2 — ALPN h2 negotiation handles the upgrade automatically.

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';

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

  Server.OnCommandGet := procedure(AContext: TIdContext;
    ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo)
  begin
    AResponseInfo.ContentText := 'Hello over HTTP/' + IfThen(ARequestInfo.HTTP2, '2', '1.1');
  end;

  Server.Active := True;
end;
// uses: sgcWebSocket
TsgcWebSocketHTTPServer *Server = new TsgcWebSocketHTTPServer(this);
Server->Port = 443;
Server->SSL  = true;
Server->Specifications->HTTP2 = true;
Server->Active = true;

Was steckt drin

TsgcWebSocketHTTPServer with HTTP/2 aktiviert — share one TLS endpoint between HTTP/1.1, HTTP/2 and WebSocket.

ALPN negotiation

During the TLS handshake the server advertises both http/1.1 and h2. The client picks the protocol; the server dispatches accordingly — no separate listening socket needed.

WebSocket coexistence

WebSocket clients still upgrade through the HTTP/1.1 path. RFC 8441 (Bootstrapping WebSockets with HTTP/2) wird unterstützt via Specifications.RFC8441.

HPACK + stream framing

Built-in HPACK encoder for response headers and a stream-multiplexing core that dispatches each request on its own stream-id, with priority hints respected.

Server push

Server push (PUSH_PROMISE) wird unterstützt but is jetzt deprecated — modern clients ignore it; consider 103 Early Hints or HTTP/3 for hints instead.

TLS choice

Set SSLOptions.IOHandler to iohOpenSSL (plattformübergreifend) or iohSChannel (Windows). HTTP/2 requires TLS 1.2+ as per RFC 7540 / 9113 deployment.

Connection metrics

Each HTTP/2 connection exposes stream count, RTT estimates, total bytes in/out und die negotiated SETTINGS frame parameters via OnHTTP2Settings.

Spezifikationen und Referenzen

Maßgebliche Quellen für das Protokoll, das diese Komponente implementiert.

Dokumentation & Demos

Springe direkt zur Komponentenreferenz, lade das einsatzbereite Demo-Projekt herunter und teste die Testversion.

Online-Hilfe — TsgcWebSocketHTTPServer Vollständige Eigenschaften-, Methoden- und Ereignisreferenz für diese Komponente.
Demo Project — Demos\20.HTTP_Protocol\01.HTTP2_Server_And_Client Einsatzbereites Beispielprojekt. Im sgcWebSockets-Paket enthalten — lade unten die Testversion herunter.
Technisches Dokument (PDF) Funktionen, Schnellstart, Codebeispiele für Delphi & C++ Builder und Primärquellenreferenzen — nur für diese Komponente.
Benutzerhandbuch (PDF) Umfassendes Handbuch zu jeder Komponente der Bibliothek.

Ready to Serve HTTP/2 from Delphi?

Download the free trial and serve HTTP/1.1, HTTP/2 and WebSocket from a single TLS endpoint.