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.
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.
The same TsgcWebSocketHTTPServer used for WebSocket and HTTP/1.1 also serves HTTP/2 over TLS — toggle Specifications.HTTP2, ALPN handles the rest.
TsgcWebSocketHTTPServer
Windows, macOS, Linux, iOS, Android
Professional / Enterprise
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;
TsgcWebSocketHTTPServer with HTTP/2 aktiviert — share one TLS endpoint between HTTP/1.1, HTTP/2 and WebSocket.
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 clients still upgrade through the HTTP/1.1 path. RFC 8441 (Bootstrapping WebSockets with HTTP/2) wird unterstützt via Specifications.RFC8441.
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 (PUSH_PROMISE) wird unterstützt but is jetzt deprecated — modern clients ignore it; consider 103 Early Hints or HTTP/3 for hints instead.
Set SSLOptions.IOHandler to iohOpenSSL (plattformübergreifend) or iohSChannel (Windows). HTTP/2 requires TLS 1.2+ as per RFC 7540 / 9113 deployment.
Each HTTP/2 connection exposes stream count, RTT estimates, total bytes in/out und die negotiated SETTINGS frame parameters via OnHTTP2Settings.
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. | Öffnen | |
| Demo Project — Demos\20.HTTP_Protocol\01.HTTP2_Server_And_Client Einsatzbereites Beispielprojekt. Im sgcWebSockets-Paket enthalten — lade unten die Testversion herunter. | Öffnen | |
| Technisches Dokument (PDF) Funktionen, Schnellstart, Codebeispiele für Delphi & C++ Builder und Primärquellenreferenzen — nur für diese Komponente. | Öffnen | |
| Benutzerhandbuch (PDF) Umfassendes Handbuch zu jeder Komponente der Bibliothek. | Öffnen |