Class Http3GrpcResponseWriter
- All Implemented Interfaces:
GrpcStreamResponseWriter
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.
-
Field Summary
Fields inherited from class org.mockserver.responsewriter.ResponseWriter
configuration, mockServerLogger -
Constructor Summary
ConstructorsConstructorDescriptionHttp3GrpcResponseWriter(Configuration configuration, MockServerLogger mockServerLogger, io.netty.channel.ChannelHandlerContext ctx, GrpcProtoDescriptorStore descriptorStore, String grpcService, String grpcMethod) -
Method Summary
Modifier and TypeMethodDescriptionvoidsendResponse(HttpRequest request, HttpResponse response) voidwriteGrpcStreamResponse(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-messageDelay, then a trailing HEADERS frame carryinggrpc-status/grpc-message, followed by a QUIC stream output shutdown (or connection close when configured).Methods inherited from class org.mockserver.responsewriter.ResponseWriter
addConnectionHeader, writeResponse, writeResponse, writeResponse
-
Constructor Details
-
Http3GrpcResponseWriter
public Http3GrpcResponseWriter(Configuration configuration, MockServerLogger mockServerLogger, io.netty.channel.ChannelHandlerContext ctx, GrpcProtoDescriptorStore descriptorStore, String grpcService, String grpcMethod)
-
-
Method Details
-
sendResponse
- Specified by:
sendResponsein classResponseWriter
-
writeGrpcStreamResponse
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-messageDelay, then a trailing HEADERS frame carryinggrpc-status/grpc-message, followed by a QUIC stream output shutdown (or connection close when configured).Mirrors the HTTP/2
GrpcStreamResponseActionHandlerscheduling pattern, reusingGrpcStreamMessageEncoderfor byte-identical framing. Delays are scheduled on the QUIC stream's own event-loop executor so writes stay ordered.- Specified by:
writeGrpcStreamResponsein interfaceGrpcStreamResponseWriter- Parameters:
grpcStreamResponse- the matched server-streaming actionrequest- the originating request (for logging / descriptor lookup)
-