- All Implemented Interfaces:
org.mockserver.responsewriter.StreamErrorWriter
- Direct Known Subclasses:
TransformingHttp3ResponseWriter
ResponseWriter that serialises the MockServer HttpResponse
as HTTP/3 frames and writes them to a QUIC stream channel.
This allows the standard request-processing pipeline (HttpState,
HttpActionHandler) to write responses identically regardless of
whether the request arrived via HTTP/1.1, HTTP/2, or HTTP/3.
Streaming support: when the response carries a
StreamingBody (SSE, chunked proxy forwarding, LLM streaming),
the headers are sent immediately and each chunk is forwarded as an HTTP/3
DATA frame. The QUIC stream output is shut down when the stream completes.
Backpressure is implemented via StreamingBody.chunkWritten(int): each
chunk write completion reports its bytes, which requests the next upstream read
once the unwritten backlog has drained.
A response to HEAD is its header section alone, static or streamed, keeping content-length. A
1xx that ends the exchange is its header section alone, and its stream is reset with H3_NO_ERROR.
-
Field Summary
Fields inherited from class org.mockserver.responsewriter.ResponseWriter
configuration, mockServerLogger -
Constructor Summary
ConstructorsConstructorDescriptionHttp3ResponseWriter(org.mockserver.configuration.Configuration configuration, org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.channel.ChannelHandlerContext ctx) -
Method Summary
Modifier and TypeMethodDescriptionAn action that writes its own response (SSE, a streamed LLM response) writes HTTP/1.1 objects, which this stream's HTTP/3 frame codec cannot take, soHttp3HttpObjectEncoderis added ahead of the request's handler to turn them into HTTP/3 frames.voidsendResponse(org.mockserver.model.HttpRequest request, org.mockserver.model.HttpResponse response) voidClose the whole QUIC connection at once withH3_INTERNAL_ERROR(a CONNECTION_CLOSE frame), failing every stream on it: QUIC runs on UDP, so there is no TCP reset to send.voidwriteStreamError(long errorCode) Reset the QUIC stream with the supplied HTTP/3 error code (RESET_STREAM, RFC 9114 section 4.1).Methods inherited from class org.mockserver.responsewriter.ResponseWriter
addConnectionHeader, writeDataPlanePreflightResponse, writeResponse, writeResponse, writeResponse
-
Constructor Details
-
Http3ResponseWriter
public Http3ResponseWriter(org.mockserver.configuration.Configuration configuration, org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.channel.ChannelHandlerContext ctx)
-
-
Method Details
-
writeStreamError
public void writeStreamError(long errorCode) Reset the QUIC stream with the supplied HTTP/3 error code (RESET_STREAM, RFC 9114 section 4.1). Only this request stream is reset; other streams on the QUIC connection are unaffected. No ByteBuf is allocated, so there is nothing to release.- Specified by:
writeStreamErrorin interfaceorg.mockserver.responsewriter.StreamErrorWriter
-
writeConnectionReset
public void writeConnectionReset()Close the whole QUIC connection at once withH3_INTERNAL_ERROR(a CONNECTION_CLOSE frame), failing every stream on it: QUIC runs on UDP, so there is no TCP reset to send.- Specified by:
writeConnectionResetin interfaceorg.mockserver.responsewriter.StreamErrorWriter
-
respondingDirectly
An action that writes its own response (SSE, a streamed LLM response) writes HTTP/1.1 objects, which this stream's HTTP/3 frame codec cannot take, soHttp3HttpObjectEncoderis added ahead of the request's handler to turn them into HTTP/3 frames. It is added synchronously, from whichever thread this runs on, so the writes that follow pass through it.- Overrides:
respondingDirectlyin classorg.mockserver.responsewriter.ResponseWriter
-
sendResponse
public void sendResponse(org.mockserver.model.HttpRequest request, org.mockserver.model.HttpResponse response) - Specified by:
sendResponsein classorg.mockserver.responsewriter.ResponseWriter
-