Class HttpServerResponse
- All Implemented Interfaces:
MutinyDelegate,StreamBase,WriteStream<Buffer>
An instance of this is created and associated to every instance of
HttpServerRequest that.
It allows the developer to control the HTTP response that is sent back to the client for a particular HTTP request.
It contains methods that allow HTTP headers and trailers to be set, and for a body to be written out to the response.
It also allows files to be streamed by the kernel directly from disk to the outgoing HTTP connection, bypassing user space altogether (where supported by the underlying operating system). This is a very efficient way of serving files from the server since buffers do not have to be read one by one from the file and written to the outgoing socket.
It implements WriteStream so it can be used with
Pipe to pipe data with flow control.
original non Mutiny-ified interface using Vert.x codegen.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHttpServerResponse(io.vertx.core.http.HttpServerResponse delegate) HttpServerResponse(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionbodyEndHandler(Runnable handler) longvoidclose()Deprecated.booleanclosed()closeHandler(Runnable handler) drainHandler(Runnable handler) io.smallrye.mutiny.Uni<Void>end()Same asend()but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>Same asend()but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>Same asend()but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>Same asend()but with anhandlercalled when the operation completesBlocking variant ofWriteStream.end().endAndAwait(Buffer chunk) Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer).endAndAwait(String chunk) Blocking variant ofend(String).endAndAwait(String chunk, String enc) Blocking variant ofend(String,String).voidVariant ofWriteStream.end()that ignores the result of the operation.voidendAndForget(Buffer chunk) Variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.voidendAndForget(String chunk) Variant ofend(String)that ignores the result of the operation.voidendAndForget(String chunk, String enc) Variant ofend(String,String)that ignores the result of the operation.booleanended()endHandler(Runnable handler) booleanexceptionHandler(Consumer<Throwable> handler) io.vertx.core.http.HttpServerResponseintinthashCode()headers()headersEndHandler(Runnable handler) booleanbooleanstatic HttpServerResponsenewInstance(io.vertx.core.http.HttpServerResponse arg) io.smallrye.mutiny.Uni<HttpServerResponse>push(io.vertx.core.http.HttpMethod method, HostAndPort authority, String path, MultiMap headers) Same aspush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<HttpServerResponse>Likepush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)with the host copied from the current request.io.smallrye.mutiny.Uni<HttpServerResponse>Likepush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)with the host copied from the current request.io.smallrye.mutiny.Uni<HttpServerResponse>Likepush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)with no headers.io.smallrye.mutiny.Uni<HttpServerResponse>Push a response to the client.pushAndAwait(io.vertx.core.http.HttpMethod method, HostAndPort authority, String path, MultiMap headers) pushAndAwait(io.vertx.core.http.HttpMethod method, String path) Blocking variant ofpush(HttpMethod,String).pushAndAwait(io.vertx.core.http.HttpMethod method, String path, MultiMap headers) Blocking variant ofpush(HttpMethod,String,io.vertx.mutiny.core.MultiMap).pushAndAwait(io.vertx.core.http.HttpMethod method, String host, String path) Blocking variant ofpush(HttpMethod,String,String).pushAndAwait(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Blocking variant ofpush(HttpMethod,String,String,io.vertx.mutiny.core.MultiMap).pushAndForget(io.vertx.core.http.HttpMethod method, HostAndPort authority, String path, MultiMap headers) Variant ofpush(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,String,io.vertx.mutiny.core.MultiMap)that ignores the result of the operation.pushAndForget(io.vertx.core.http.HttpMethod method, String path) Variant ofpush(HttpMethod,String)that ignores the result of the operation.pushAndForget(io.vertx.core.http.HttpMethod method, String path, MultiMap headers) Variant ofpush(HttpMethod,String,io.vertx.mutiny.core.MultiMap)that ignores the result of the operation.pushAndForget(io.vertx.core.http.HttpMethod method, String host, String path) Variant ofpush(HttpMethod,String,String)that ignores the result of the operation.pushAndForget(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Variant ofpush(HttpMethod,String,String,io.vertx.mutiny.core.MultiMap)that ignores the result of the operation.putHeader(CharSequence name, CharSequence value) putHeader(CharSequence name, Iterable<CharSequence> values) putTrailer(CharSequence name, CharSequence value) putTrailer(CharSequence name, Iterable<CharSequence> value) putTrailer(String name, Iterable<String> values) putTrailer(String name, String value) removeCookie(String name) removeCookie(String name, boolean invalidate) removeCookie(String name, String domain, String path) removeCookie(String name, String domain, String path, boolean invalidate) removeCookies(String name) removeCookies(String name, boolean invalidate) booleanreset()booleanreset(long code) io.smallrye.mutiny.Uni<Void>send()Send the request with an empty body.io.smallrye.mutiny.Uni<Void>Send the request with a bufferbody.io.smallrye.mutiny.Uni<Void>send(ReadStream<Buffer> body) Send the request with a streambody.io.smallrye.mutiny.Uni<Void>Send the request with a stringbody.io.smallrye.mutiny.Uni<Void>send(Flow.Publisher<Buffer> body) Send the request with a streambody.Blocking variant ofsend().sendAndAwait(Buffer body) Blocking variant ofsend(io.vertx.mutiny.core.buffer.Buffer).sendAndAwait(ReadStream<Buffer> body) Blocking variant ofsend(io.vertx.mutiny.core.streams.ReadStream).sendAndAwait(String body) Blocking variant ofsend(String).sendAndAwait(Flow.Publisher<Buffer> body) Blocking variant ofsend(Flow$Publisher).voidVariant ofsend()that ignores the result of the operation.voidsendAndForget(Buffer body) Variant ofsend(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.voidsendAndForget(ReadStream<Buffer> body) Variant ofsend(io.vertx.mutiny.core.streams.ReadStream)that ignores the result of the operation.voidsendAndForget(String body) Variant ofsend(String)that ignores the result of the operation.voidsendAndForget(Flow.Publisher<Buffer> body) Variant ofsend(Flow$Publisher)that ignores the result of the operation.io.smallrye.mutiny.Uni<Void>LikesendFile(java.lang.String)but providing a handler which will be notified once the file has been completely written to the wire.io.smallrye.mutiny.Uni<Void>LikesendFile(java.lang.String)but providing a handler which will be notified once the file has been completely written to the wire.io.smallrye.mutiny.Uni<Void>LikesendFile(java.lang.String)but providing a handler which will be notified once the file has been completely written to the wire.sendFileAndAwait(String filename) Blocking variant ofsendFile(String).sendFileAndAwait(String filename, long offset) Blocking variant ofsendFile(String,long).sendFileAndAwait(String filename, long offset, long length) Blocking variant ofsendFile(String,long,long).sendFileAndForget(String filename) Variant ofsendFile(String)that ignores the result of the operation.sendFileAndForget(String filename, long offset) Variant ofsendFile(String,long)that ignores the result of the operation.sendFileAndForget(String filename, long offset, long length) Variant ofsendFile(String,long,long)that ignores the result of the operation.setChunked(boolean chunked) setStatusCode(int statusCode) setStatusMessage(String statusMessage) setStreamPriority(io.vertx.core.http.StreamPriority streamPriority) setWriteQueueMaxSize(int maxSize) intstreamId()toString()trailers()io.smallrye.mutiny.Uni<Void>Same as but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completeswriteAndAwait(Buffer data) Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer).writeAndAwait(String chunk) Blocking variant ofwrite(String).writeAndAwait(String chunk, String enc) Blocking variant ofwrite(String,String).voidwriteAndForget(Buffer data) Variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.voidwriteAndForget(String chunk) Variant ofwrite(String)that ignores the result of the operation.voidwriteAndForget(String chunk, String enc) Variant ofwrite(String,String)that ignores the result of the operation.writeCustomFrame(int type, int flags, Buffer payload) writeCustomFrame(HttpFrame frame) io.smallrye.mutiny.Uni<Void>writeEarlyHints(MultiMap headers) Same aswriteEarlyHints(io.vertx.mutiny.core.MultiMap)but with anhandlercalled when the operation completeswriteEarlyHintsAndAwait(MultiMap headers) Blocking variant ofwriteEarlyHints(io.vertx.mutiny.core.MultiMap).voidwriteEarlyHintsAndForget(MultiMap headers) Variant ofwriteEarlyHints(io.vertx.mutiny.core.MultiMap)that ignores the result of the operation.boolean
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
HttpServerResponse
public HttpServerResponse(io.vertx.core.http.HttpServerResponse delegate) -
HttpServerResponse
-
-
Method Details
-
getDelegate
public io.vertx.core.http.HttpServerResponse getDelegate()- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<Buffer>- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
toSubscriber
-
write
Same as but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Specified by:
writein interfaceWriteStream<Buffer>- Parameters:
data-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
writeAndAwaitin interfaceWriteStream<Buffer>- Parameters:
data-- Returns:
- the Void instance produced by the operation.
-
writeAndForget
Variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.This method subscribes on the result of
io.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)but you don't need to compose it with other operations.- Specified by:
writeAndForgetin interfaceWriteStream<Buffer>- Parameters:
data-
-
end
Same asend()but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Specified by:
endin interfaceWriteStream<Buffer>- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
Blocking variant ofWriteStream.end().This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
endAndAwaitin interfaceWriteStream<Buffer>- Returns:
- the Void instance produced by the operation.
-
endAndForget
public void endAndForget()Variant ofWriteStream.end()that ignores the result of the operation.This method subscribes on the result of
WriteStream.end(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromWriteStream.end()but you don't need to compose it with other operations.- Specified by:
endAndForgetin interfaceWriteStream<Buffer>
-
writeQueueFull
public boolean writeQueueFull()- Specified by:
writeQueueFullin interfaceWriteStream<Buffer>- Returns:
trueif write queue is full
-
exceptionHandler
- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<Buffer>- Parameters:
handler- the exception handler- Returns:
-
setWriteQueueMaxSize
- Specified by:
setWriteQueueMaxSizein interfaceWriteStream<Buffer>- Parameters:
maxSize- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
- Specified by:
drainHandlerin interfaceWriteStream<Buffer>- Parameters:
handler- the handler- Returns:
-
getStatusCode
public int getStatusCode()- Returns:
- the HTTP status code of the response. The default is
200representingOK.
-
setStatusCode
- Parameters:
statusCode-- Returns:
- a reference to this, so the API can be used fluently
-
getStatusMessage
- Returns:
- the HTTP status message of the response. If this is not specified a default value will be used depending on what
setStatusCode(int)has been set to.
-
setStatusMessage
- Parameters:
statusMessage-- Returns:
- a reference to this, so the API can be used fluently
-
setChunked
- Parameters:
chunked-- Returns:
- a reference to this, so the API can be used fluently
-
isChunked
public boolean isChunked()- Returns:
- is the response chunked?
-
headers
- Returns:
- The HTTP headers
-
putHeader
- Parameters:
name- the header namevalue- the header value.- Returns:
- a reference to this, so the API can be used fluently
-
trailers
- Returns:
- The HTTP trailers
-
putTrailer
- Parameters:
name- the trailer namevalue- the trailer value- Returns:
- a reference to this, so the API can be used fluently
-
closeHandler
- Parameters:
handler- the handler- Returns:
-
endHandler
- Parameters:
handler- the handler- Returns:
-
write
Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
chunk-enc-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
Blocking variant ofwrite(String,String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
chunk-enc-- Returns:
- the Void instance produced by the operation.
-
writeAndForget
Variant ofwrite(String,String)that ignores the result of the operation.This method subscribes on the result of
write(String,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwrite(String,String)but you don't need to compose it with other operations.- Parameters:
chunk-enc-
-
write
Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
chunk-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
Blocking variant ofwrite(String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
chunk-- Returns:
- the Void instance produced by the operation.
-
writeAndForget
Variant ofwrite(String)that ignores the result of the operation.This method subscribes on the result of
write(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwrite(String)but you don't need to compose it with other operations.- Parameters:
chunk-
-
writeContinue
- Returns:
- a reference to this, so the API can be used fluently
-
writeEarlyHints
Same aswriteEarlyHints(io.vertx.mutiny.core.MultiMap)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
headers- headers to write- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
writeEarlyHintsAndAwait
Blocking variant ofwriteEarlyHints(io.vertx.mutiny.core.MultiMap).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
headers- headers to write- Returns:
- the Void instance produced by the operation.
-
writeEarlyHintsAndForget
Variant ofwriteEarlyHints(io.vertx.mutiny.core.MultiMap)that ignores the result of the operation.This method subscribes on the result of
writeEarlyHints(io.vertx.mutiny.core.MultiMap), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromwriteEarlyHints(io.vertx.mutiny.core.MultiMap)but you don't need to compose it with other operations.- Parameters:
headers- headers to write
-
end
Same asend()but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
chunk-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
Blocking variant ofend(String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
chunk-- Returns:
- the Void instance produced by the operation.
-
endAndForget
Variant ofend(String)that ignores the result of the operation.This method subscribes on the result of
end(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromend(String)but you don't need to compose it with other operations.- Parameters:
chunk-
-
end
Same asend()but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
chunk-enc-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
Blocking variant ofend(String,String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
chunk-enc-- Returns:
- the Void instance produced by the operation.
-
endAndForget
Variant ofend(String,String)that ignores the result of the operation.This method subscribes on the result of
end(String,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromend(String,String)but you don't need to compose it with other operations.- Parameters:
chunk-enc-
-
end
Same asend()but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Specified by:
endin interfaceWriteStream<Buffer>- Parameters:
chunk-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
endAndAwaitin interfaceWriteStream<Buffer>- Parameters:
chunk-- Returns:
- the Void instance produced by the operation.
-
endAndForget
Variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.This method subscribes on the result of
io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)but you don't need to compose it with other operations.- Specified by:
endAndForgetin interfaceWriteStream<Buffer>- Parameters:
chunk-
-
send
Send the request with an empty body.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
sendAndAwait
Blocking variant ofsend().This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
sendAndForget
public void sendAndForget() -
send
Send the request with a stringbody.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
body-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
sendAndAwait
Blocking variant ofsend(String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body-- Returns:
- the Void instance produced by the operation.
-
sendAndForget
Variant ofsend(String)that ignores the result of the operation.This method subscribes on the result of
send(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsend(String)but you don't need to compose it with other operations.- Parameters:
body-
-
send
Send the request with a bufferbody.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
body-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
sendAndAwait
Blocking variant ofsend(io.vertx.mutiny.core.buffer.Buffer).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body-- Returns:
- the Void instance produced by the operation.
-
sendAndForget
Variant ofsend(io.vertx.mutiny.core.buffer.Buffer)that ignores the result of the operation.This method subscribes on the result of
send(io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsend(io.vertx.mutiny.core.buffer.Buffer)but you don't need to compose it with other operations.- Parameters:
body-
-
send
Send the request with a streambody.If the
HttpHeadersis set then the request assumes this is the length of the {stream}, otherwise the request will set a chunkedHttpHeaders.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
body-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
sendAndAwait
Blocking variant ofsend(io.vertx.mutiny.core.streams.ReadStream).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body-- Returns:
- the Void instance produced by the operation.
-
sendAndForget
Variant ofsend(io.vertx.mutiny.core.streams.ReadStream)that ignores the result of the operation.This method subscribes on the result of
send(io.vertx.mutiny.core.streams.ReadStream), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsend(io.vertx.mutiny.core.streams.ReadStream)but you don't need to compose it with other operations.- Parameters:
body-
-
send
Send the request with a streambody.If the
HttpHeadersis set then the request assumes this is the length of the {stream}, otherwise the request will set a chunkedHttpHeaders.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
body-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
sendAndAwait
Blocking variant ofsend(Flow$Publisher).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
body-- Returns:
- the Void instance produced by the operation.
-
sendAndForget
Variant ofsend(Flow$Publisher)that ignores the result of the operation.This method subscribes on the result of
send(Flow$Publisher), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsend(Flow$Publisher)but you don't need to compose it with other operations.- Parameters:
body-
-
sendFile
LikesendFile(java.lang.String)but providing a handler which will be notified once the file has been completely written to the wire.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
filename- path to the file to serve- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
sendFileAndAwait
Blocking variant ofsendFile(String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
filename- path to the file to serve- Returns:
- the Void instance produced by the operation.
-
sendFileAndForget
Variant ofsendFile(String)that ignores the result of the operation.This method subscribes on the result of
sendFile(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendFile(String)but you don't need to compose it with other operations.- Parameters:
filename- path to the file to serve- Returns:
- the instance of HttpServerResponse to chain method calls.
-
sendFile
LikesendFile(java.lang.String)but providing a handler which will be notified once the file has been completely written to the wire.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
filename- path to the file to serveoffset- the offset to serve from- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
sendFileAndAwait
Blocking variant ofsendFile(String,long).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
filename- path to the file to serveoffset- the offset to serve from- Returns:
- the Void instance produced by the operation.
-
sendFileAndForget
Variant ofsendFile(String,long)that ignores the result of the operation.This method subscribes on the result of
sendFile(String,long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendFile(String,long)but you don't need to compose it with other operations.- Parameters:
filename- path to the file to serveoffset- the offset to serve from- Returns:
- the instance of HttpServerResponse to chain method calls.
-
sendFile
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> sendFile(String filename, long offset, long length) LikesendFile(java.lang.String)but providing a handler which will be notified once the file has been completely written to the wire.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
filename- path to the file to serveoffset- the offset to serve fromlength- length the number of bytes to send- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
sendFileAndAwait
Blocking variant ofsendFile(String,long,long).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
filename- path to the file to serveoffset- the offset to serve fromlength- length the number of bytes to send- Returns:
- the Void instance produced by the operation.
-
sendFileAndForget
Variant ofsendFile(String,long,long)that ignores the result of the operation.This method subscribes on the result of
sendFile(String,long,long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsendFile(String,long,long)but you don't need to compose it with other operations.- Parameters:
filename- path to the file to serveoffset- the offset to serve fromlength- length the number of bytes to send- Returns:
- the instance of HttpServerResponse to chain method calls.
-
close
Deprecated.instead useHttpConnection.close()orreset(long), this method is removed in Vert.x 5 -
ended
public boolean ended()- Returns:
- has the response already ended?
-
closed
public boolean closed()- Returns:
- has the underlying TCP connection corresponding to the request already been closed?
-
headWritten
public boolean headWritten()- Returns:
- have the headers for the response already been written?
-
headersEndHandler
- Parameters:
handler- the handler- Returns:
-
bodyEndHandler
- Parameters:
handler- the handler- Returns:
-
bytesWritten
public long bytesWritten()- Returns:
- the total number of bytes written for the body of the response.
-
streamId
public int streamId()- Returns:
- the id of the stream of this response, for HTTP/1.x
-
push
@CheckReturnValue public io.smallrye.mutiny.Uni<HttpServerResponse> push(io.vertx.core.http.HttpMethod method, String host, String path) Likepush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)with no headers.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
method-host-path-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
pushAndAwait
public HttpServerResponse pushAndAwait(io.vertx.core.http.HttpMethod method, String host, String path) Blocking variant ofpush(HttpMethod,String,String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
method-host-path-- Returns:
- the HttpServerResponse instance produced by the operation.
-
pushAndForget
public HttpServerResponse pushAndForget(io.vertx.core.http.HttpMethod method, String host, String path) Variant ofpush(HttpMethod,String,String)that ignores the result of the operation.This method subscribes on the result of
push(HttpMethod,String,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompush(HttpMethod,String,String)but you don't need to compose it with other operations.- Parameters:
method-host-path-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
push
@CheckReturnValue public io.smallrye.mutiny.Uni<HttpServerResponse> push(io.vertx.core.http.HttpMethod method, String path, MultiMap headers) Likepush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)with the host copied from the current request.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
method-path-headers-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
pushAndAwait
public HttpServerResponse pushAndAwait(io.vertx.core.http.HttpMethod method, String path, MultiMap headers) Blocking variant ofpush(HttpMethod,String,io.vertx.mutiny.core.MultiMap).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
method-path-headers-- Returns:
- the HttpServerResponse instance produced by the operation.
-
pushAndForget
public HttpServerResponse pushAndForget(io.vertx.core.http.HttpMethod method, String path, MultiMap headers) Variant ofpush(HttpMethod,String,io.vertx.mutiny.core.MultiMap)that ignores the result of the operation.This method subscribes on the result of
push(HttpMethod,String,io.vertx.mutiny.core.MultiMap), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompush(HttpMethod,String,io.vertx.mutiny.core.MultiMap)but you don't need to compose it with other operations.- Parameters:
method-path-headers-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
push
@CheckReturnValue public io.smallrye.mutiny.Uni<HttpServerResponse> push(io.vertx.core.http.HttpMethod method, String path) Likepush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)with the host copied from the current request.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
method-path-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
pushAndAwait
Blocking variant ofpush(HttpMethod,String).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
method-path-- Returns:
- the HttpServerResponse instance produced by the operation.
-
pushAndForget
Variant ofpush(HttpMethod,String)that ignores the result of the operation.This method subscribes on the result of
push(HttpMethod,String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompush(HttpMethod,String)but you don't need to compose it with other operations.- Parameters:
method-path-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
push
@CheckReturnValue public io.smallrye.mutiny.Uni<HttpServerResponse> push(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Push a response to the client. Thehandlerwill be notified with a success when the push can be sent and with a failure when the client has disabled push or reset the push before it has been sent. Thehandlermay be queued if the client has reduced the maximum number of streams the server can push concurrently. Push can be sent only for peer initiated streams and if the response is not ended.Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
method- the method of the promised requesthost-path- the path of the promised requestheaders- the headers of the promised request- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
pushAndAwait
public HttpServerResponse pushAndAwait(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Blocking variant ofpush(HttpMethod,String,String,io.vertx.mutiny.core.MultiMap).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
method- the method of the promised requesthost-path- the path of the promised requestheaders- the headers of the promised request- Returns:
- the HttpServerResponse instance produced by the operation.
-
pushAndForget
public HttpServerResponse pushAndForget(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Variant ofpush(HttpMethod,String,String,io.vertx.mutiny.core.MultiMap)that ignores the result of the operation.This method subscribes on the result of
push(HttpMethod,String,String,io.vertx.mutiny.core.MultiMap), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompush(HttpMethod,String,String,io.vertx.mutiny.core.MultiMap)but you don't need to compose it with other operations.- Parameters:
method- the method of the promised requesthost-path- the path of the promised requestheaders- the headers of the promised request- Returns:
- the instance of HttpServerResponse to chain method calls.
-
push
@CheckReturnValue public io.smallrye.mutiny.Uni<HttpServerResponse> push(io.vertx.core.http.HttpMethod method, HostAndPort authority, String path, MultiMap headers) Same aspush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)but with anhandlercalled when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
method-authority-path-headers-- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
pushAndAwait
public HttpServerResponse pushAndAwait(io.vertx.core.http.HttpMethod method, HostAndPort authority, String path, MultiMap headers) Blocking variant ofpush(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,String,io.vertx.mutiny.core.MultiMap).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
method-authority-path-headers-- Returns:
- the HttpServerResponse instance produced by the operation.
-
pushAndForget
public HttpServerResponse pushAndForget(io.vertx.core.http.HttpMethod method, HostAndPort authority, String path, MultiMap headers) Variant ofpush(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,String,io.vertx.mutiny.core.MultiMap)that ignores the result of the operation.This method subscribes on the result of
push(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,String,io.vertx.mutiny.core.MultiMap), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompush(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,String,io.vertx.mutiny.core.MultiMap)but you don't need to compose it with other operations.- Parameters:
method-authority-path-headers-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
reset
public boolean reset()- Returns:
-
reset
public boolean reset(long code) - Parameters:
code- the error code- Returns:
truewhen reset has been performed
-
writeCustomFrame
- Parameters:
type- the 8-bit frame typeflags- the 8-bit frame flagspayload- the frame payload- Returns:
- a reference to this, so the API can be used fluently
-
writeCustomFrame
- Parameters:
frame- the frame to write- Returns:
- the instance of HttpServerResponse to chain method calls.
-
setStreamPriority
- Parameters:
streamPriority- the priority for this request's stream- Returns:
- the instance of HttpServerResponse to chain method calls.
-
addCookie
- Parameters:
cookie- the cookie- Returns:
- a reference to this, so the API can be used fluently
-
removeCookie
- Parameters:
name- the name of the cookie- Returns:
- the cookie, if it existed, or null
-
removeCookie
- Parameters:
name- the name of the cookieinvalidate-- Returns:
- the cookie, if it existed, or
null
-
removeCookies
- Parameters:
name- the name of the cookie- Returns:
- a read only set of affected cookies, if they existed, or an empty set.
-
removeCookies
- Parameters:
name- the name of the cookieinvalidate- invalidate from the user agent- Returns:
- a read only set of affected cookies, if they existed, or an empty set.
-
removeCookie
- Parameters:
name- the name of the cookiedomain- the domain of the cookiepath- the path of the cookie- Returns:
- the cookie, if it existed, or
null
-
removeCookie
- Parameters:
name- the name of the cookiedomain- the domain of the cookiepath- the path of the cookieinvalidate-- Returns:
- the cookie, if it existed, or
null
-
putHeader
- Parameters:
name-value-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putHeader
- Parameters:
name-values-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putHeader
- Parameters:
name-values-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putTrailer
- Parameters:
name-value-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putTrailer
- Parameters:
name-values-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putTrailer
- Parameters:
name-value-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
newInstance
-
HttpConnection.close()orreset(long), this method is removed in Vert.x 5