Servidor HTTP/2
Sirve HTTP/2 (h2) junto a HTTP/1.1 y WebSocket en un mismo puerto TLS mediante TsgcWebSocketHTTPServer. La negociación ALPN, HPACK y la multiplexación de streams están integradas.
Sirve HTTP/2 (h2) junto a HTTP/1.1 y WebSocket en un mismo puerto TLS mediante TsgcWebSocketHTTPServer. La negociación ALPN, HPACK y la multiplexación de streams están integradas.
El mismo TsgcWebSocketHTTPServer que se usa para WebSocket y HTTP/1.1 también sirve HTTP/2 sobre TLS — activa Specifications.HTTP2, ALPN se encarga del resto.
TsgcWebSocketHTTPServer
Windows, macOS, Linux, iOS, Android
Professional / Enterprise
En una instancia de TsgcWebSocketHTTPServer, activa TLS y conmuta Specifications.HTTP2 — la negociación ALPN h2 gestiona el upgrade automáticamente.
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 con HTTP/2 habilitado — comparte un único endpoint TLS entre HTTP/1.1, HTTP/2 y 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) is supported 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) is supported but is now deprecated — modern clients ignore it; consider 103 Early Hints or HTTP/3 for hints instead.
Set SSLOptions.IOHandler to iohOpenSSL (cross-platform) 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 and the negotiated SETTINGS frame parameters via OnHTTP2Settings.
Enlace directo a la referencia del componente, descarga el proyecto demo listo para ejecutar y la prueba gratuita.
| Ayuda en línea — TsgcWebSocketHTTPServer Referencia completa de propiedades, métodos y eventos de este componente. | Abrir | |
| Proyecto demo — Demos\20.HTTP_Protocol\01.HTTP2_Server_And_Client Proyecto de ejemplo listo para ejecutar. Se incluye en el paquete sgcWebSockets — descarga la prueba gratuita más abajo. | Abrir | |
| Documento técnico (PDF) Características, inicio rápido, ejemplos de código para Delphi y C++ Builder y referencias de fuentes primarias — solo este componente. | Abrir | |
| Manual de usuario (PDF) Manual completo que cubre todos los componentes de la biblioteca. | Abrir |