TsgcHTTP3Server › 메서드 › SendResponse

SendResponse 메서드

요청 스트림에서 HTTP/3 응답(HEADERS 및 DATA 프레임)을 전송합니다.

구문

procedure SendResponse(const aQUICConn: TsgcQUICServerConnection; aStreamId: Int64; const aResponse: TsgcHTTP3Response);

Parameters

NameType설명
aQUICConnconst TsgcQUICServerConnection응답이 기록되는 QUIC 연결.
aStreamIdInt64응답이 속하는 요청 스트림의 식별자.
aResponseconst TsgcHTTP3Response전송할 응답입니다. 호출 전에 StatusCode, ContentType, 선택적 Headers 및 Data 본문을 설정하십시오.

설명

SendResponse는 응답 헤더를 QPACK으로 인코딩하여 HEADERS 프레임에 넣고, 응답에 본문이 있으면 DATA 프레임을 추가하여 두 프레임 모두 QUIC을 통해 요청 스트림에 씁니다. 상태 코드는 :status pseudo-header로 전송되고, 본문이 있을 때 content-length 헤더가 자동으로 추가됩니다.

일반적인 요청 흐름에서는 SendResponse를 호출할 필요가 없습니다. 서버는 TsgcHTTP3Response(StatusCode 기본값 200)를 생성하고, 애플리케이션이 채울 수 있도록 OnH3Request를 발생시킨 후 자동으로 전송합니다. SendResponse는 해당 흐름 외부에서 응답을 생성해야 하는 고급 시나리오를 위해 노출되며, SendPush에서도 내부적으로 사용됩니다.

예제


oResponse := TsgcHTTP3Response.Create;
try
  oResponse.StatusCode := 200;
  oResponse.ContentType := 'text/plain';
  oResponse.Data := TEncoding.UTF8.GetBytes('Hello HTTP/3');
  oServer.SendResponse(aConnection, aStreamId, oResponse);
finally
  oResponse.Free;
end;

메서드로 돌아가기