TsgcWebSocketHTTPServerEventi › OnHTTP2BeforeAsyncRequest

OnHTTP2BeforeAsyncRequest Evento

Viene generato prima che una richiesta HTTP/2 venga accodata, consentendo all'applicazione di scegliere se eseguirla nel pool di thread o nel thread di connessione.

Sintassi

property OnHTTP2BeforeAsyncRequest: TsgcWSOnBeforeHttp2AsyncRequest;
// TsgcWSOnBeforeHttp2AsyncRequest = procedure(Sender: TObject; Connection: TsgcWSConnection; const ARequestInfo: TIdHTTPRequestInfo; var Async: Boolean) of object

Valore predefinito

Note

Quando HTTP2Options.PoolOfThreads.Enabled è True, il server smista le richieste HTTP/2 in ingresso su un pool di worker (HTTP2Options.Threads) per sfruttare il multiplexing HTTP/2. OnHTTP2BeforeAsyncRequest viene sollevato per ogni richiesta prima che venga accodata: ispezionare ARequestInfo.Document per decidere e impostare Async su True (predefinito) per eseguire nel pool di thread o su False per eseguire nel thread della connessione. Instradare le richieste brevi al thread della connessione evita il sovraccarico del pool mantenendo le richieste lente in thread separati, che è la strategia di ottimizzazione raccomandata.

Esempio


procedure OnHTTP2BeforeAsyncRequest(Sender: TObject; Connection: TsgcWSConnection;
  const ARequestInfo: TIdHTTPRequestInfo; var Async: Boolean);
begin
  if ARequestInfo.Document = '/fast-request' then
    Async := False;
end;

Torna agli Eventi