Top Description Inners Methods
org.eclipse.jetty.server

public Interface Response

extends Sink
Known Direct Implementers
org.eclipse.jetty.server.Response.Wrapper, org.eclipse.jetty.server.internal.HttpChannelState.ChannelResponse
Imports
java.io.OutputStream, java.nio.ByteBuffer, java.util.ListIterator, java.util.concurrent.CompletableFuture, .TimeoutException, java.util.function.Supplier, org.eclipse.jetty.http.ComplianceViolationException, .CookieCompliance, .HttpCookie, .HttpException, .HttpField, .HttpFields, .HttpHeader, .HttpHeaderValue, .HttpMethod, .HttpStatus, .HttpURI, .HttpVersion, .Trailers, org.eclipse.jetty.io.ByteBufferPool, .Content, .QuietException, org.eclipse.jetty.server.handler.ErrorHandler, org.eclipse.jetty.server.internal.HttpChannelState, org.eclipse.jetty.util.Callback, .StringUtil, .URIUtil, org.slf4j.Logger, .LoggerFactory

The representation of an HTTP response, for any protocol version (HTTP/1.1, HTTP/2, HTTP/3).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Method Summary

Modifier and TypeMethod and Description
public static void
addCookie(Response
the HTTP response
response
,
HttpCookie
the HTTP cookie to add
cookie
)

Adds an HTTP HttpHeader#SET_COOKIE header to the response.

public static <
the response type
T
>
T

Returns:

the response as the given type, or null
as
(Response
the response to unwrap
response
,
Class<T>
the response type to find
type
)

Unwraps the given response, recursively, until the wrapped instance is an instance of the given type, otherwise returns null.

public static OutputStream

Returns:

a buffering OutputStream
asBufferedOutputStream
(Request
the request from which to get the buffering sink's settings
request
,
Response
the response to wrap
response
)

Wraps a Response as a OutputStream that performs buffering.

public static Content.Sink

Returns:

a buffering Content.Sink
asBufferedSink
(Request
the request from which to get the buffering sink's settings
request
,
Response
the response to wrap
response
)

Wraps a Response as a Content.Sink that performs buffering.

public static long
getContentBytesWritten(Response
the HTTP response
response
)

Returns: the number of response content bytes written to the network so far, or -1 if the number is unknown

public HttpFields.Mutable
getHeaders()

Returns: the response HTTP headers

public static Response

Returns:

the innermost wrapped response instance
getOriginalResponse
(Response
the response to unwrap
response
)

Unwraps the given response until the innermost wrapped response instance.

public Request
getRequest()

Returns: the Request associated with this Response

public int
getStatus()

Returns: the response HTTP status code

public Supplier<HttpFields>
getTrailersSupplier()

Returns: a supplier for the HTTP trailers

public boolean

Returns:

true if last==true has been passed to write(boolean, ByteBuffer, Callback).
hasLastWrite
()

Returns whether the last write has been initiated on the response.

public boolean

Returns:

whether this response has already been committed
isCommitted
()

Returns whether this response has already been committed.

public boolean

Returns:

whether the response completed successfully
isCompletedSuccessfully
()

Returns whether the response completed successfully.

public static Content.Chunk.Processor

Returns:

A chunk processor that will add trailer chunks to the response's trailer supplied fields.
newTrailersChunkProcessor
(Response
The response for which to process a trailers chunk. If the Response#setTrailersSupplier(Supplier) method has not been called prior to this method, then a noop processor is returned.
response
)

Returns a chunk processor suitable to be passed to the Content#copy(Content.Source, Content.Sink, Content.Chunk.Processor, Callback) method, that will handle Trailers chunks by adding their fields to the HttpFields supplied by Response#getTrailersSupplier().

public static void
putCookie(Response
the HTTP response
response
,
HttpCookie
the HTTP cookie to add
cookie
)

Put a HTTP HttpHeader#SET_COOKIE header to the response.

public static void
replaceCookie(Response
the HTTP response
response
,
HttpCookie
the HTTP cookie to add
cookie
)

Replace a cookie

public void
reset()

Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.

public static void
sendRedirect(Request
the HTTP request
request
,
Response
the HTTP response
response
,
Callback
the callback to complete
callback
,
String
the redirect location as an absolute URI or encoded relative URI path.
location
)

Sends a HTTP redirect status code to the given location, without consuming the available request content.

public static void
sendRedirect(Request
the HTTP request
request
,
Response
the HTTP response
response
,
Callback
the callback to complete
callback
,
String
the redirect location as an absolute URI or encoded relative URI path.
location
,
boolean
whether to consumer the available request content
consumeAvailable
)

Sends HTTP redirect status code to the given location, without consuming the available request content.

public static void
sendRedirect(Request
the HTTP request
request
,
Response
the HTTP response
response
,
Callback
the callback to complete
callback
,
int
the redirect HTTP status code
code
,
String
the redirect location as an absolute URI or encoded relative URI path.
location
,
boolean
whether to consumer the available request content
consumeAvailable
)

Sends a 302 HTTP redirect status code to the given location.

public void
setStatus(int
the response HTTP status code
code
)

Set the response HTTP status code.

public void
setTrailersSupplier(Supplier<HttpFields>
a supplier for the HTTP trailers
trailers
)

Sets the supplier for the HTTP trailers.

public static String

Returns:

the full redirect "Location" URL (including scheme, host, port, path, etc...)
toRedirectURI
(Request
the request the redirect should be based on (needed when relative locations are provided, so that server name, scheme, port can be built out properly)
request
,
String
the redirect location as an absolute URI or encoded relative URI path. If a relative path starts with '/', then it is relative to the root, otherwise it is relative to the request.
location
)

Common point to generate a proper "Location" header for redirects.

public void
write(boolean
whether the ByteBuffer is the last to write
last
,
ByteBuffer
the ByteBuffer to write
byteBuffer
,
Callback
the callback to notify when the write operation is complete
callback
)

Redeclares org.eclipse.jetty.io.Content.Sink.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

public static void
writeError(Request
the HTTP request
request
,
Response
the HTTP response
response
,
Callback
the callback to complete
callback
,
Throwable
the cause of the error
cause
)

Writes an error response with HTTP status code 500.

public static void
writeError(Request
the HTTP request
request
,
Response
the HTTP response
response
,
Callback
the callback to complete
callback
,
int
the error HTTP status code
status
)

Writes an error response with the given HTTP status code.

public static void
writeError(Request
the HTTP request
request
,
Response
the HTTP response
response
,
Callback
the callback to complete
callback
,
int
the error HTTP status code
status
,
String
the error message to write in the response content
message
)

Writes an error response with the given HTTP status code, and the given message in the response content.

public static void
writeError(Request
the HTTP request
request
,
Response
the HTTP response
response
,
Callback
the callback to complete
callback
,
int
the error HTTP status code
status
,
String
the error message to write in the response content
message
,
Throwable
the cause of the error
cause
)

Writes an error response with the given HTTP status code, and the given message in the response content.

public CompletableFuture<Void>

Returns:

a CompletableFuture with the result of the write
writeInterim
(int
the interim HTTP status code
status
,
HttpFields
the HTTP headers
headers
)

Writes an HTTP interim response, with the given HTTP status code and HTTP headers.

Inherited from org.eclipse.jetty.io.Content.Sink:
asBufferedasOutputStreamasSubscriberwritewrite

Method Detail

addCookieback to summary
public static void addCookie(Response response, HttpCookie cookie)

Adds an HTTP HttpHeader#SET_COOKIE header to the response.

Parameters
response:Response

the HTTP response

cookie:HttpCookie

the HTTP cookie to add

See Also
putCookie(Response, HttpCookie)
asback to summary
public static <T> T as(Response response, Class<T> type)

Unwraps the given response, recursively, until the wrapped instance is an instance of the given type, otherwise returns null.

Parameters
<T>
the response type
response:Response

the response to unwrap

type:Class<T>

the response type to find

Returns:T

the response as the given type, or null

Annotations
@SuppressWarnings:unchecked
See Also
Wrapper
asBufferedOutputStreamback to summary
public static OutputStream asBufferedOutputStream(Request request, Response response)

Wraps a Response as a OutputStream that performs buffering. The necessary ByteBufferPool is taken from the request's connector while the size and direction of the buffer is read from the request's HttpConfiguration.

This is equivalent to:

Content.Sink.asOutputStream(Response.asBufferedSink(request, response))

Parameters
request:Request

the request from which to get the buffering sink's settings

response:Response

the response to wrap

Returns:OutputStream

a buffering OutputStream

asBufferedSinkback to summary
public static Content.Sink asBufferedSink(Request request, Response response)

Wraps a Response as a Content.Sink that performs buffering. The necessary ByteBufferPool is taken from the request's connector while the size, direction of the buffer and commit size are read from the request's HttpConfiguration.

Parameters
request:Request

the request from which to get the buffering sink's settings

response:Response

the response to wrap

Returns:Content.Sink

a buffering Content.Sink

getContentBytesWrittenback to summary
public static long getContentBytesWritten(Response response)
Parameters
response:Response

the HTTP response

Returns:long

the number of response content bytes written to the network so far, or -1 if the number is unknown

getHeadersback to summary
public HttpFields.Mutable getHeaders()
Returns:HttpFields.Mutable

the response HTTP headers

getOriginalResponseback to summary
public static Response getOriginalResponse(Response response)

Unwraps the given response until the innermost wrapped response instance.

Parameters
response:Response

the response to unwrap

Returns:Response

the innermost wrapped response instance

See Also
Wrapper
getRequestback to summary
public Request getRequest()
Returns:Request

the Request associated with this Response

getStatusback to summary
public int getStatus()
Returns:int

the response HTTP status code

getTrailersSupplierback to summary
public Supplier<HttpFields> getTrailersSupplier()
Returns:Supplier<HttpFields>

a supplier for the HTTP trailers

hasLastWriteback to summary
public boolean hasLastWrite()

Returns whether the last write has been initiated on the response.

Returns:boolean

true if last==true has been passed to write(boolean, ByteBuffer, Callback).

isCommittedback to summary
public boolean isCommitted()

Returns whether this response has already been committed.

Committing a response means that the HTTP status code and HTTP headers cannot be modified anymore, typically because they have already been serialized and sent over the network.

Returns:boolean

whether this response has already been committed

isCompletedSuccessfullyback to summary
public boolean isCompletedSuccessfully()

Returns whether the response completed successfully.

The response HTTP status code, HTTP headers and content have been successfully serialized and sent over the network without errors.

Returns:boolean

whether the response completed successfully

newTrailersChunkProcessorback to summary
public static Content.Chunk.Processor newTrailersChunkProcessor(Response response)

Returns a chunk processor suitable to be passed to the Content#copy(Content.Source, Content.Sink, Content.Chunk.Processor, Callback) method, that will handle Trailers chunks by adding their fields to the HttpFields supplied by Response#getTrailersSupplier().

This is specifically useful for writing trailers that have been received via the Content.Source#read() API, for example when echoing a request to a response:

  Content.copy(request, response, Response.asTrailerChunkHandler(response), callback);
Parameters
response:Response

The response for which to process a trailers chunk. If the Response#setTrailersSupplier(Supplier) method has not been called prior to this method, then a noop processor is returned.

Returns:Content.Chunk.Processor

A chunk processor that will add trailer chunks to the response's trailer supplied fields.

See Also
Content#copy(Content.Source, Content.Sink, Content.Chunk.Processor, Callback), Trailers
putCookieback to summary
public static void putCookie(Response response, HttpCookie cookie)

Put a HTTP HttpHeader#SET_COOKIE header to the response.

If a matching HttpHeader#SET_COOKIE already exists for matching name, path, domain etc. then it will be replaced.

Parameters
response:Response

the HTTP response

cookie:HttpCookie

the HTTP cookie to add

See Also
addCookie(Response, HttpCookie)
replaceCookieback to summary
public static void replaceCookie(Response response, HttpCookie cookie)

Replace a cookie

Parameters
response:Response

the HTTP response

cookie:HttpCookie

the HTTP cookie to add

Annotations
@Deprecated
resetback to summary
public void reset()

Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.

Exceptions
IllegalStateException:
if the response is already committed
sendRedirectback to summary
public static void sendRedirect(Request request, Response response, Callback callback, String location)

Sends a HTTP redirect status code to the given location, without consuming the available request content. The HttpStatus#SEE_OTHER_303 code is used, unless the request is HTTP/1.0, in which case HttpStatus#MOVED_TEMPORARILY_302 is used, unless the request is not a GET and the protocol is HTTP/1.1 or later, in which case a HttpStatus#SEE_OTHER_303 is used to make the client consistently redirect with a GET.

Parameters
request:Request

the HTTP request

response:Response

the HTTP response

callback:Callback

the callback to complete

location:String

the redirect location as an absolute URI or encoded relative URI path.

See Also
sendRedirect(Request, Response, Callback, int, String, boolean)
sendRedirectback to summary
public static void sendRedirect(Request request, Response response, Callback callback, String location, boolean consumeAvailable)

Sends HTTP redirect status code to the given location, without consuming the available request content. The HttpStatus#SEE_OTHER_303 code is used, unless the request is HTTP/1.0, in which case HttpStatus#MOVED_TEMPORARILY_302 is used, unless the request is not a GET and the protocol is HTTP/1.1 or later, in which case a HttpStatus#SEE_OTHER_303 is used to make the client consistently redirect with a GET.

Parameters
request:Request

the HTTP request

response:Response

the HTTP response

callback:Callback

the callback to complete

location:String

the redirect location as an absolute URI or encoded relative URI path.

consumeAvailable:boolean

whether to consumer the available request content

See Also
sendRedirect(Request, Response, Callback, int, String, boolean)
sendRedirectback to summary
public static void sendRedirect(Request request, Response response, Callback callback, int code, String location, boolean consumeAvailable)

Sends a 302 HTTP redirect status code to the given location.

Parameters
request:Request

the HTTP request

response:Response

the HTTP response

callback:Callback

the callback to complete

code:int

the redirect HTTP status code

location:String

the redirect location as an absolute URI or encoded relative URI path.

consumeAvailable:boolean

whether to consumer the available request content

Exceptions
IllegalArgumentException:
if the status code is not a redirect, or the location is null
IllegalStateException:
if the response is already committed
See Also
toRedirectURI(Request, String)
setStatusback to summary
public void setStatus(int code)

Set the response HTTP status code.

Parameters
code:int

the response HTTP status code

setTrailersSupplierback to summary
public void setTrailersSupplier(Supplier<HttpFields> trailers)

Sets the supplier for the HTTP trailers.

The method Supplier#get() may be called by the implementation multiple times, so it is important that the same value is returned in every invocation.

Example:

// Correct usage.
HttpFields.Mutable trailers = HttpFields.build();
response.setTrailersSupplier(() -> trailers);

// WRONG usage, as the value changes for
// every invocation of supplier.get().
response.setTrailersSupplier(() -> HttpFields.build());
Parameters
trailers:Supplier<HttpFields>

a supplier for the HTTP trailers

toRedirectURIback to summary
public static String toRedirectURI(Request request, String location)

Common point to generate a proper "Location" header for redirects.

Parameters
request:Request

the request the redirect should be based on (needed when relative locations are provided, so that server name, scheme, port can be built out properly)

location:String

the redirect location as an absolute URI or encoded relative URI path. If a relative path starts with '/', then it is relative to the root, otherwise it is relative to the request.

Returns:String

the full redirect "Location" URL (including scheme, host, port, path, etc...)

writeback to summary
public void write(boolean last, ByteBuffer byteBuffer, Callback callback)

Redeclares org.eclipse.jetty.io.Content.Sink.write.

Doc from org.eclipse.jetty.io.Content.Sink.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Callback and a call to this method.

The invocation of the passed Callback is serialized with previous calls of this method, so that it is not invoked until any invocation of the callback of a previous call to this method has returned.

Thus a Callback should not block waiting for a callback of a future call to this method.

Parameters
last:boolean

whether the ByteBuffer is the last to write

byteBuffer:ByteBuffer

the ByteBuffer to write

callback:Callback

the callback to notify when the write operation is complete

Annotations
@Override
writeErrorback to summary
public static void writeError(Request request, Response response, Callback callback, Throwable cause)

Writes an error response with HTTP status code 500.

The error Request.Handler returned by Context#getErrorHandler(), if any, is invoked.

Parameters
request:Request

the HTTP request

response:Response

the HTTP response

callback:Callback

the callback to complete

cause:Throwable

the cause of the error

writeErrorback to summary
public static void writeError(Request request, Response response, Callback callback, int status)

Writes an error response with the given HTTP status code.

The error Request.Handler returned by Context#getErrorHandler(), if any, is invoked.

Parameters
request:Request

the HTTP request

response:Response

the HTTP response

callback:Callback

the callback to complete

status:int

the error HTTP status code

writeErrorback to summary
public static void writeError(Request request, Response response, Callback callback, int status, String message)

Writes an error response with the given HTTP status code, and the given message in the response content.

The error Request.Handler returned by Context#getErrorHandler(), if any, is invoked.

Parameters
request:Request

the HTTP request

response:Response

the HTTP response

callback:Callback

the callback to complete

status:int

the error HTTP status code

message:String

the error message to write in the response content

writeErrorback to summary
public static void writeError(Request request, Response response, Callback callback, int status, String message, Throwable cause)

Writes an error response with the given HTTP status code, and the given message in the response content.

The error Request.Handler returned by Context#getErrorHandler(), if any, is invoked.

Parameters
request:Request

the HTTP request

response:Response

the HTTP response

callback:Callback

the callback to complete

status:int

the error HTTP status code

message:String

the error message to write in the response content

cause:Throwable

the cause of the error

writeInterimback to summary
public CompletableFuture<Void> writeInterim(int status, HttpFields headers)

Writes an HTTP interim response, with the given HTTP status code and HTTP headers.

It is possible to write more than one interim response, for example in case of HttpStatus#EARLY_HINTS_103.

The returned CompletableFuture is notified of the result of this write, whether it succeeded or failed.

Parameters
status:int

the interim HTTP status code

headers:HttpFields

the HTTP headers

Returns:CompletableFuture<Void>

a CompletableFuture with the result of the write

org.eclipse.jetty.server back to summary

public Class Response.Wrapper

extends Object
implements Response
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.server.Response, org.eclipse.jetty.io.Content.Sink
Known Direct Subclasses
org.eclipse.jetty.server.SizeLimitHandler.SizeLimitResponseWrapper, org.eclipse.jetty.server.handler.BufferedResponseHandler.BufferedResponse, org.eclipse.jetty.server.handler.ContextResponse, org.eclipse.jetty.server.handler.EventsHandler.EventsResponse, org.eclipse.jetty.server.handler.StatisticsHandler.MinimumDataRateHandler.MinimumDataRateResponse, org.eclipse.jetty.server.handler.ThreadLimitHandler.LimitedResponse, org.eclipse.jetty.server.handler.gzip.GzipResponseAndCallback

Field Summary

Modifier and TypeField and Description
private final Request
private final Response

Constructor Summary

AccessConstructor and Description
public
Wrapper(Request request, Response wrapped)

Method Summary

Modifier and TypeMethod and Description
public HttpFields.Mutable
public Request
public int
public Supplier<HttpFields>
public Response
public boolean
hasLastWrite()

Implements org.eclipse.jetty.server.Response.hasLastWrite.

Returns whether the last write has been initiated on the response.

public boolean
isCommitted()

Implements org.eclipse.jetty.server.Response.isCommitted.

Returns whether this response has already been committed.

public boolean
isCompletedSuccessfully()

Implements org.eclipse.jetty.server.Response.isCompletedSuccessfully.

Returns whether the response completed successfully.

public void
reset()

Implements org.eclipse.jetty.server.Response.reset.

Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.

public void
setStatus(int
the response HTTP status code
code
)

Implements org.eclipse.jetty.server.Response.setStatus.

Set the response HTTP status code.

public void
setTrailersSupplier(Supplier<HttpFields>
a supplier for the HTTP trailers
trailers
)

Implements org.eclipse.jetty.server.Response.setTrailersSupplier.

Sets the supplier for the HTTP trailers.

public void
write(boolean
whether the ByteBuffer is the last to write
last
,
ByteBuffer
the ByteBuffer to write
byteBuffer
,
Callback
the callback to notify when the write operation is complete
callback
)

Implements org.eclipse.jetty.server.Response.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

public CompletableFuture<Void>
writeInterim(int
the interim HTTP status code
status
,
HttpFields
the HTTP headers
headers
)

Implements org.eclipse.jetty.server.Response.writeInterim.

Writes an HTTP interim response, with the given HTTP status code and HTTP headers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_requestback to summary
private final Request _request
_wrappedback to summary
private final Response _wrapped

Constructor Detail

Wrapperback to summary
public Wrapper(Request request, Response wrapped)

Method Detail

getHeadersback to summary
public HttpFields.Mutable getHeaders()

Implements org.eclipse.jetty.server.Response.getHeaders.

Returns:HttpFields.Mutable

Doc from org.eclipse.jetty.server.Response.getHeaders.

the response HTTP headers

Annotations
@Override
getRequestback to summary
public Request getRequest()

Implements org.eclipse.jetty.server.Response.getRequest.

Returns:Request

Doc from org.eclipse.jetty.server.Response.getRequest.

the Request associated with this Response

Annotations
@Override
getStatusback to summary
public int getStatus()

Implements org.eclipse.jetty.server.Response.getStatus.

Returns:int

Doc from org.eclipse.jetty.server.Response.getStatus.

the response HTTP status code

Annotations
@Override
getTrailersSupplierback to summary
public Supplier<HttpFields> getTrailersSupplier()

Implements org.eclipse.jetty.server.Response.getTrailersSupplier.

Returns:Supplier<HttpFields>

Doc from org.eclipse.jetty.server.Response.getTrailersSupplier.

a supplier for the HTTP trailers

Annotations
@Override
getWrappedback to summary
public Response getWrapped()
hasLastWriteback to summary
public boolean hasLastWrite()

Implements org.eclipse.jetty.server.Response.hasLastWrite.

Doc from org.eclipse.jetty.server.Response.hasLastWrite.

Returns whether the last write has been initiated on the response.

Returns:boolean

true if last==true has been passed to write(boolean, ByteBuffer, Callback).

Annotations
@Override
isCommittedback to summary
public boolean isCommitted()

Implements org.eclipse.jetty.server.Response.isCommitted.

Doc from org.eclipse.jetty.server.Response.isCommitted.

Returns whether this response has already been committed.

Committing a response means that the HTTP status code and HTTP headers cannot be modified anymore, typically because they have already been serialized and sent over the network.

Returns:boolean

whether this response has already been committed

Annotations
@Override
isCompletedSuccessfullyback to summary
public boolean isCompletedSuccessfully()

Implements org.eclipse.jetty.server.Response.isCompletedSuccessfully.

Doc from org.eclipse.jetty.server.Response.isCompletedSuccessfully.

Returns whether the response completed successfully.

The response HTTP status code, HTTP headers and content have been successfully serialized and sent over the network without errors.

Returns:boolean

whether the response completed successfully

Annotations
@Override
resetback to summary
public void reset()

Implements org.eclipse.jetty.server.Response.reset.

Doc from org.eclipse.jetty.server.Response.reset.

Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.

Annotations
@Override
setStatusback to summary
public void setStatus(int code)

Implements org.eclipse.jetty.server.Response.setStatus.

Doc from org.eclipse.jetty.server.Response.setStatus.

Set the response HTTP status code.

Parameters
code:int

the response HTTP status code

Annotations
@Override
setTrailersSupplierback to summary
public void setTrailersSupplier(Supplier<HttpFields> trailers)

Implements org.eclipse.jetty.server.Response.setTrailersSupplier.

Doc from org.eclipse.jetty.server.Response.setTrailersSupplier.

Sets the supplier for the HTTP trailers.

The method Supplier#get() may be called by the implementation multiple times, so it is important that the same value is returned in every invocation.

Example:

// Correct usage.
HttpFields.Mutable trailers = HttpFields.build();
response.setTrailersSupplier(() -> trailers);

// WRONG usage, as the value changes for
// every invocation of supplier.get().
response.setTrailersSupplier(() -> HttpFields.build());
Parameters
trailers:Supplier<HttpFields>

a supplier for the HTTP trailers

Annotations
@Override
writeback to summary
public void write(boolean last, ByteBuffer byteBuffer, Callback callback)

Implements org.eclipse.jetty.server.Response.write.

Doc from org.eclipse.jetty.server.Response.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Callback and a call to this method.

The invocation of the passed Callback is serialized with previous calls of this method, so that it is not invoked until any invocation of the callback of a previous call to this method has returned.

Thus a Callback should not block waiting for a callback of a future call to this method.

Parameters
last:boolean

whether the ByteBuffer is the last to write

byteBuffer:ByteBuffer

the ByteBuffer to write

callback:Callback

the callback to notify when the write operation is complete

Annotations
@Override
writeInterimback to summary
public CompletableFuture<Void> writeInterim(int status, HttpFields headers)

Implements org.eclipse.jetty.server.Response.writeInterim.

Doc from org.eclipse.jetty.server.Response.writeInterim.

Writes an HTTP interim response, with the given HTTP status code and HTTP headers.

It is possible to write more than one interim response, for example in case of HttpStatus#EARLY_HINTS_103.

The returned CompletableFuture is notified of the result of this write, whether it succeeded or failed.

Parameters
status:int

the interim HTTP status code

headers:HttpFields

the HTTP headers

Returns:CompletableFuture<Void>

a CompletableFuture with the result of the write

Annotations
@Override