Class Http3GrpcResponseWriter

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

public class Http3GrpcResponseWriter extends org.mockserver.responsewriter.ResponseWriter implements org.mockserver.responsewriter.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.

  • Field Summary

    Fields inherited from class org.mockserver.responsewriter.ResponseWriter

    configuration, mockServerLogger
  • Constructor Summary

    Constructors
    Constructor
    Description
    Http3GrpcResponseWriter(org.mockserver.configuration.Configuration configuration, org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.channel.ChannelHandlerContext ctx, org.mockserver.grpc.GrpcProtoDescriptorStore descriptorStore, String grpcService, String grpcMethod)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    sendResponse(org.mockserver.model.HttpRequest request, org.mockserver.model.HttpResponse response)
     
    void
    writeGrpcStreamResponse(org.mockserver.model.GrpcStreamResponse grpcStreamResponse, org.mockserver.model.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).

    Methods inherited from class org.mockserver.responsewriter.ResponseWriter

    addConnectionHeader, writeResponse, writeResponse, writeResponse

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Http3GrpcResponseWriter

      public Http3GrpcResponseWriter(org.mockserver.configuration.Configuration configuration, org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.channel.ChannelHandlerContext ctx, org.mockserver.grpc.GrpcProtoDescriptorStore descriptorStore, String grpcService, String grpcMethod)
  • Method Details

    • sendResponse

      public void sendResponse(org.mockserver.model.HttpRequest request, org.mockserver.model.HttpResponse response)
      Specified by:
      sendResponse in class org.mockserver.responsewriter.ResponseWriter
    • writeGrpcStreamResponse

      public void writeGrpcStreamResponse(org.mockserver.model.GrpcStreamResponse grpcStreamResponse, org.mockserver.model.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 org.mockserver.responsewriter.GrpcStreamResponseWriter