Class VertxHttpResponse
java.lang.Object
dev.resteasy.vertx.server.VertxHttpResponse
- All Implemented Interfaces:
Closeable, AutoCloseable, org.jboss.resteasy.spi.HttpResponse
Vert.x adapter that bridges
HttpServerResponse to RESTEasy's HttpResponse SPI.
This adapter handles:
- Status code and headers conversion to Vert.x format
- Response body output stream (via
ChunkOutputStream) - Chunked encoding and response finalization
- Exception tracking from Vert.x async handlers
The response is considered committed after headers are sent (either via chunked streaming
or when finish() is called).
- Author:
- Bill Burke, Norman Maurer
-
Constructor Summary
ConstructorsConstructorDescriptionVertxHttpResponse(io.vertx.core.http.HttpServerResponse response, org.jboss.resteasy.spi.ResteasyProviderFactory providerFactory) Creates a new response adapter.VertxHttpResponse(io.vertx.core.http.HttpServerResponse response, org.jboss.resteasy.spi.ResteasyProviderFactory providerFactory, io.vertx.core.http.HttpMethod method) Creates a new response adapter with optional HTTP method. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNewCookie(jakarta.ws.rs.core.NewCookie cookie) voidfinish()Finishes the response by flushing output and ending the Vert.x response.voidintbooleanvoidPrepares the response output stream.voidreset()voidsendError(int status) voidvoidvoidsetStatus(int status) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jboss.resteasy.spi.HttpResponse
close, getAsyncOutputStream, setSuppressExceptionDuringChunkedTransfer, suppressExceptionDuringChunkedTransfer
-
Constructor Details
-
VertxHttpResponse
public VertxHttpResponse(io.vertx.core.http.HttpServerResponse response, org.jboss.resteasy.spi.ResteasyProviderFactory providerFactory) Creates a new response adapter.- Parameters:
response- the Vert.x HTTP server responseproviderFactory- the RESTEasy provider factory for header serialization
-
VertxHttpResponse
public VertxHttpResponse(io.vertx.core.http.HttpServerResponse response, org.jboss.resteasy.spi.ResteasyProviderFactory providerFactory, io.vertx.core.http.HttpMethod method) Creates a new response adapter with optional HTTP method.- Parameters:
response- the Vert.x HTTP server responseproviderFactory- the RESTEasy provider factory for header serializationmethod- the HTTP method (if HEAD, no output stream is created)
-
-
Method Details
-
setOutputStream
- Specified by:
setOutputStreamin interfaceorg.jboss.resteasy.spi.HttpResponse
-
getStatus
public int getStatus()- Specified by:
getStatusin interfaceorg.jboss.resteasy.spi.HttpResponse
-
setStatus
public void setStatus(int status) - Specified by:
setStatusin interfaceorg.jboss.resteasy.spi.HttpResponse
-
getOutputHeaders
-
getOutputStream
- Specified by:
getOutputStreamin interfaceorg.jboss.resteasy.spi.HttpResponse- Throws:
IOException
-
addNewCookie
public void addNewCookie(jakarta.ws.rs.core.NewCookie cookie) - Specified by:
addNewCookiein interfaceorg.jboss.resteasy.spi.HttpResponse
-
sendError
- Specified by:
sendErrorin interfaceorg.jboss.resteasy.spi.HttpResponse- Throws:
IOException
-
sendError
- Specified by:
sendErrorin interfaceorg.jboss.resteasy.spi.HttpResponse- Throws:
IOException
-
isCommitted
public boolean isCommitted()- Specified by:
isCommittedin interfaceorg.jboss.resteasy.spi.HttpResponse
-
reset
public void reset()- Specified by:
resetin interfaceorg.jboss.resteasy.spi.HttpResponse
-
prepareOutputStream
public void prepareOutputStream()Prepares the response output stream.Sets the status code, enables chunked mode if applicable, and writes all headers. Called when the response output stream is first written to.
-
finish
Finishes the response by flushing output and ending the Vert.x response.This must be called to complete the HTTP response. If not already committed, headers will be written. The response cannot be modified after this call.
- Throws:
IOException- if the response has already failed or cannot be finished
-
flushBuffer
- Specified by:
flushBufferin interfaceorg.jboss.resteasy.spi.HttpResponse- Throws:
IOException
-