- All Implemented Interfaces:
org.eclipse.jetty.io.Content.Sink,Response
- Direct Known Subclasses:
ContextResponse,GzipResponseAndCallback,StatisticsHandler.MinimumDataRateHandler.MinimumDataRateResponse
- Enclosing interface:
Response
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Response
Response.Wrapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.jetty.http.HttpFields.MutableintSupplier<org.eclipse.jetty.http.HttpFields>booleanReturns whether this response has already been committed.booleanReturns whether the response completed successfully.voidreset()Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.voidsetStatus(int code) voidsetTrailersSupplier(Supplier<org.eclipse.jetty.http.HttpFields> trailers) Sets the supplier for the HTTP trailers.voidwrite(boolean last, ByteBuffer byteBuffer, org.eclipse.jetty.util.Callback callback) writeInterim(int status, org.eclipse.jetty.http.HttpFields headers) Writes anHTTP interim response, with the given HTTP status code and HTTP headers.
-
Constructor Details
-
Wrapper
-
-
Method Details
-
getWrapped
-
getRequest
- Specified by:
getRequestin interfaceResponse- Returns:
- the
Requestassociated with thisResponse
-
getStatus
public int getStatus() -
setStatus
public void setStatus(int code) -
getHeaders
public org.eclipse.jetty.http.HttpFields.Mutable getHeaders()- Specified by:
getHeadersin interfaceResponse- Returns:
- the response HTTP headers
-
getTrailersSupplier
- Specified by:
getTrailersSupplierin interfaceResponse- Returns:
- a supplier for the HTTP trailers
-
setTrailersSupplier
Description copied from interface:ResponseSets 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());- Specified by:
setTrailersSupplierin interfaceResponse- Parameters:
trailers- a supplier for the HTTP trailers
-
isCommitted
public boolean isCommitted()Description copied from interface:ResponseReturns 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.
- Specified by:
isCommittedin interfaceResponse- Returns:
- whether this response has already been committed
-
isCompletedSuccessfully
public boolean isCompletedSuccessfully()Description copied from interface:ResponseReturns 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.
- Specified by:
isCompletedSuccessfullyin interfaceResponse- Returns:
- whether the response completed successfully
-
reset
public void reset()Description copied from interface:ResponseResets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.
-
writeInterim
Description copied from interface:ResponseWrites 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_HINT_103.The returned
CompletableFutureis notified of the result of this write, whether it succeeded or failed.- Specified by:
writeInterimin interfaceResponse- Parameters:
status- the interim HTTP status codeheaders- the HTTP headers- Returns:
- a
CompletableFuturewith the result of the write
-
write
Description copied from interface:ResponseThe invocation of the passed
Callbackis 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
Callbackshould not block waiting for a callback of a future call to this method.Furthermore, the invocation of the passed callback is serialized with invocations of the
Runnabledemand callback passed toRequest.demand(Runnable).
-