Package io.micronaut.http.server
Class ResponseLifecycle
java.lang.Object
io.micronaut.http.server.ResponseLifecycle
This class handles encoding of the HTTP response in a server-agnostic way. Note that while this
class is internal, it is used from servlet and must not be broken.
- Since:
- 4.8.0
- Author:
- Jonas Konrad
-
Constructor Summary
ConstructorDescriptionResponseLifecycle
(RouteExecutor routeExecutor, MessageBodyHandlerRegistry messageBodyHandlerRegistry, ConversionService conversionService, ByteBodyFactory byteBodyFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected @NonNull CloseableByteBody
concatenate
(@NonNull Publisher<ByteBody> items) protected @NonNull CloseableByteBody
concatenateJson
(@NonNull Publisher<ByteBody> items) final @NonNull ExecutionFlow<? extends ByteBodyHttpResponse<?>>
encodeHttpResponseSafe
(@NonNull HttpRequest<?> httpRequest, @NonNull HttpResponse<?> response) Encode the response.protected ExecutionFlow<? extends ByteBodyHttpResponse<?>>
encodeNoBody
(HttpResponse<?> response) Encode the given response without body, either because it has none or because this is a HEAD response.protected final @NonNull ExecutionFlow<? extends ByteBodyHttpResponse<?>>
handleStreamingError
(@NonNull HttpRequest<?> request, @NonNull Throwable t) Handle an error that happened before the first item of a streaming response.The IO executor for blocking writers.protected <T> @NonNull ResponseBodyWriter<T>
wrap
(@NonNull MessageBodyWriter<T> messageBodyWriter) Transform the given writer into aResponseBodyWriter
.
-
Constructor Details
-
ResponseLifecycle
public ResponseLifecycle(RouteExecutor routeExecutor, MessageBodyHandlerRegistry messageBodyHandlerRegistry, ConversionService conversionService, ByteBodyFactory byteBodyFactory)
-
-
Method Details
-
ioExecutor
The IO executor for blocking writers.- Returns:
- The blocking executor
-
wrap
@NonNull protected <T> @NonNull ResponseBodyWriter<T> wrap(@NonNull @NonNull MessageBodyWriter<T> messageBodyWriter) Transform the given writer into aResponseBodyWriter
.- Type Parameters:
T
- The writer type- Parameters:
messageBodyWriter
- The writer- Returns:
- The response writer
-
encodeHttpResponseSafe
@NonNull public final @NonNull ExecutionFlow<? extends ByteBodyHttpResponse<?>> encodeHttpResponseSafe(@NonNull @NonNull HttpRequest<?> httpRequest, @NonNull @NonNull HttpResponse<?> response) Encode the response.- Parameters:
httpRequest
- The request that triggered this responseresponse
- The unencoded response- Returns:
- The encoded response
-
encodeNoBody
Encode the given response without body, either because it has none or because this is a HEAD response.- Parameters:
response
- The response- Returns:
- The encoded response
-
concatenate
@NonNull protected @NonNull CloseableByteBody concatenate(@NonNull @NonNull Publisher<ByteBody> items) - Parameters:
items
- The items- Returns:
- The concatenated body
- See Also:
-
concatenateJson
@NonNull protected @NonNull CloseableByteBody concatenateJson(@NonNull @NonNull Publisher<ByteBody> items) - Parameters:
items
- The items- Returns:
- The concatenated body
- See Also:
-
handleStreamingError
@NonNull protected final @NonNull ExecutionFlow<? extends ByteBodyHttpResponse<?>> handleStreamingError(@NonNull @NonNull HttpRequest<?> request, @NonNull @NonNull Throwable t) Handle an error that happened before the first item of a streaming response.- Parameters:
request
- The requestt
- The error- Returns:
- The encoded error response
-