Class Http3GrpcResponseWriter

java.lang.Object
org.mockserver.responsewriter.ResponseWriter
org.mockserver.netty.http3.Http3GrpcResponseWriter
All Implemented Interfaces:
GrpcStreamResponseWriter

public class Http3GrpcResponseWriter extends ResponseWriter implements GrpcStreamResponseWriter
A ResponseWriter that writes gRPC responses over HTTP/3 with correct gRPC wire framing: initial HEADERS (:status=200, content-type=application/grpc), DATA (gRPC length-prefixed message), and trailing HEADERS (grpc-status, grpc-message).

This follows the gRPC-over-HTTP/3 convention (same as HTTP/2): the grpc-status is conveyed in a trailing HEADERS frame at end-of-stream, which gRPC clients require. The initial HEADERS frame does NOT contain grpc-status.

For error responses without a body, the "trailers-only" pattern is used: a single HEADERS frame containing both :status=200 and grpc-status (no DATA frame).

The gRPC service and method names are captured from the original request (where GrpcHttp3Adapter places them as x-grpc-service and x-grpc-method headers) rather than from the response, because the matching pipeline does not propagate these internal headers to the matched response.

  • Constructor Details

  • Method Details

    • sendResponse

      public void sendResponse(HttpRequest request, HttpResponse response)
      Specified by:
      sendResponse in class ResponseWriter
    • writeGrpcStreamResponse

      public void writeGrpcStreamResponse(GrpcStreamResponse grpcStreamResponse, HttpRequest request)
      Write a server-streaming gRPC response over HTTP/3: an initial HEADERS frame (:status=200, content-type=application/grpc, plus any configured headers), one DATA frame per message honouring per-message Delay, then a trailing HEADERS frame carrying grpc-status / grpc-message, followed by a QUIC stream output shutdown (or connection close when configured).

      Mirrors the HTTP/2 GrpcStreamResponseActionHandler scheduling pattern, reusing GrpcStreamMessageEncoder for byte-identical framing. Delays are scheduled on the QUIC stream's own event-loop executor so writes stay ordered.

      Specified by:
      writeGrpcStreamResponse in interface GrpcStreamResponseWriter
      Parameters:
      grpcStreamResponse - the matched server-streaming action
      request - the originating request (for logging / descriptor lookup)