Top Description Fields Constructors Methods
org.springframework.web.servlet.function

pack-priv final Class DefaultAsyncServerResponse

extends ErrorHandlingServerResponse
implements AsyncServerResponse
Class Inheritance
All Implemented Interfaces
org.springframework.web.servlet.function.AsyncServerResponse, org.springframework.web.servlet.function.ServerResponse
Imports
java.io.IOException, java.time.Duration, java.util.concurrent.CompletableFuture, .CompletionException, .ExecutionException, .TimeUnit, .TimeoutException, java.util.function.Function, jakarta.servlet.ServletException, jakarta.servlet.http.Cookie, .HttpServletRequest, .HttpServletResponse, org.reactivestreams.Publisher, org.springframework.core.ReactiveAdapter, .ReactiveAdapterRegistry, org.springframework.http.HttpHeaders, .HttpStatusCode, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, .MultiValueMap, org.springframework.web.context.request.async.AsyncWebRequest, .DeferredResult, .WebAsyncManager, .WebAsyncUtils, org.springframework.web.servlet.ModelAndView

Default AsyncServerResponse implementation.
Author
Arjen Poutsma
Since
5.3.2

Field Summary

Modifier and TypeField and Description
private final CompletableFuture<ServerResponse>
pack-priv static final boolean
private final Duration
Inherited from org.springframework.web.servlet.function.ErrorHandlingServerResponse:
logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ServerResponse
block()

Implements org.springframework.web.servlet.function.AsyncServerResponse.block.

Blocks indefinitely until the future response is obtained.

public MultiValueMap<String, Cookie>
cookies()

Implements org.springframework.web.servlet.function.ServerResponse.cookies.

Return the cookies of this response.

public static AsyncServerResponse
create(Object
a CompletableFuture<ServerResponse> or Publisher<ServerResponse>
obj
,
Duration
maximum time period to wait for before timing out
timeout
)

Hides org.springframework.web.servlet.function.AsyncServerResponse.create.

Create a (built) response with the given asynchronous response.

private DeferredResult<ServerResponse>
private <R> R
public HttpHeaders
headers()

Implements org.springframework.web.servlet.function.ServerResponse.headers.

Return the headers of this response.

public int
rawStatusCode()

Implements org.springframework.web.servlet.function.ServerResponse.rawStatusCode.

Deprecated

Return the status code of this response as integer.

public HttpStatusCode
statusCode()

Implements org.springframework.web.servlet.function.ServerResponse.statusCode.

Return the status code of this response.

pack-priv static void
writeAsync(HttpServletRequest request, HttpServletResponse response, DeferredResult<?> deferredResult)

public ModelAndView
writeTo(HttpServletRequest
the current request
request
,
HttpServletResponse
the response to write to
response
,
ServerResponse.Context
the context to use when writing
context
)

Implements org.springframework.web.servlet.function.ServerResponse.writeTo.

Write this response to the given servlet response.

Inherited from org.springframework.web.servlet.function.ErrorHandlingServerResponse:
addErrorHandlererrorResponsehandleError

Field Detail

futureResponseback to summary
private final CompletableFuture<ServerResponse> futureResponse
reactiveStreamsPresentback to summary
pack-priv static final boolean reactiveStreamsPresent
timeoutback to summary
private final Duration timeout
Annotations
@Nullable

Constructor Detail

DefaultAsyncServerResponseback to summary
private DefaultAsyncServerResponse(CompletableFuture<ServerResponse> futureResponse, Duration timeout)

Method Detail

blockback to summary
public ServerResponse block()

Implements org.springframework.web.servlet.function.AsyncServerResponse.block.

Doc from org.springframework.web.servlet.function.AsyncServerResponse.block.

Blocks indefinitely until the future response is obtained.

Annotations
@Override
cookiesback to summary
public MultiValueMap<String, Cookie> cookies()

Implements org.springframework.web.servlet.function.ServerResponse.cookies.

Doc from org.springframework.web.servlet.function.ServerResponse.cookies.

Return the cookies of this response.

Annotations
@Override
createback to summary
public static AsyncServerResponse create(Object obj, Duration timeout)

Hides org.springframework.web.servlet.function.AsyncServerResponse.create.

Doc from org.springframework.web.servlet.function.AsyncServerResponse.create.

Create a (built) response with the given asynchronous response. Parameter asyncResponse can be a CompletableFuture<ServerResponse> or Publisher<ServerResponse> (or any asynchronous producer of a single ServerResponse that can be adapted via the ReactiveAdapterRegistry).

Parameters
obj:Object

a CompletableFuture<ServerResponse> or Publisher<ServerResponse>

timeout:Duration

maximum time period to wait for before timing out

Returns:AsyncServerResponse

the asynchronous response

Annotations
@SuppressWarnings:rawtypes, unchecked
createDeferredResultback to summary
private DeferredResult<ServerResponse> createDeferredResult(HttpServletRequest request)
delegateback to summary
private <R> R delegate(Function<ServerResponse, R> function)
headersback to summary
public HttpHeaders headers()

Implements org.springframework.web.servlet.function.ServerResponse.headers.

Doc from org.springframework.web.servlet.function.ServerResponse.headers.

Return the headers of this response.

Annotations
@Override
rawStatusCodeback to summary
public int rawStatusCode()

Implements org.springframework.web.servlet.function.ServerResponse.rawStatusCode.

Doc from org.springframework.web.servlet.function.ServerResponse.rawStatusCode.

Deprecated

Return the status code of this response as integer.

Returns:int

the status as an integer

Annotations
@Override
@Deprecated
statusCodeback to summary
public HttpStatusCode statusCode()

Implements org.springframework.web.servlet.function.ServerResponse.statusCode.

Doc from org.springframework.web.servlet.function.ServerResponse.statusCode.

Return the status code of this response.

Returns:HttpStatusCode

the status as an HttpStatusCode value

Annotations
@Override
writeAsyncback to summary
pack-priv static void writeAsync(HttpServletRequest request, HttpServletResponse response, DeferredResult<?> deferredResult) throws ServletException, IOException
writeToback to summary
public ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, ServerResponse.Context context) throws ServletException, IOException

Implements org.springframework.web.servlet.function.ServerResponse.writeTo.

Doc from org.springframework.web.servlet.function.ServerResponse.writeTo.

Write this response to the given servlet response.

Parameters
request:HttpServletRequest

the current request

response:HttpServletResponse

the response to write to

context:ServerResponse.Context

the context to use when writing

Returns:ModelAndView

a ModelAndView to render, or null if handled directly

Annotations
@Nullable
@Override