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) long
void
close()
Deprecated.boolean
closed()
closeHandler
(Runnable handler) drainHandler
(Runnable handler) io.smallrye.mutiny.Uni<Void>
end()
Same asend()
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
Same asend()
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
Same asend()
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
Same asend()
but with anhandler
called 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)
.void
Variant ofWriteStream.end()
that ignores the result of the operation.void
endAndForget
(Buffer chunk) Variant ofio.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.void
endAndForget
(String chunk) Variant ofend(String)
that ignores the result of the operation.void
endAndForget
(String chunk, String enc) Variant ofend(String,String)
that ignores the result of the operation.boolean
ended()
endHandler
(Runnable handler) boolean
exceptionHandler
(Consumer<Throwable> handler) io.vertx.core.http.HttpServerResponse
int
int
hashCode()
headers()
headersEndHandler
(Runnable handler) boolean
boolean
static HttpServerResponse
newInstance
(io.vertx.core.http.HttpServerResponse arg) io.smallrye.mutiny.Uni<HttpServerResponse>
push
(io.vertx.core.http.HttpMethod method, HostAndPort host, String path) Likepush(io.vertx.core.http.HttpMethod, java.lang.String, java.lang.String)
with no headers.io.smallrye.mutiny.Uni<HttpServerResponse>
push
(io.vertx.core.http.HttpMethod method, HostAndPort authority, String path, MultiMap headers) Push a response to the client.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 the host copied from the current request.io.smallrye.mutiny.Uni<HttpServerResponse>
Deprecated.instead use#push(HttpMethod, HostAndPort, String, Handler)
io.smallrye.mutiny.Uni<HttpServerResponse>
Deprecated.pushAndAwait
(io.vertx.core.http.HttpMethod method, HostAndPort host, String path) Blocking variant ofpush(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,String)
.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) Deprecated.instead use#push(HttpMethod, HostAndPort, String, Handler)
pushAndAwait
(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Deprecated.pushAndForget
(io.vertx.core.http.HttpMethod method, HostAndPort host, String path) Variant ofpush(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,String)
that ignores the result of the operation.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) Deprecated.instead use#push(HttpMethod, HostAndPort, String, Handler)
pushAndForget
(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Deprecated.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) boolean
reset()
boolean
reset
(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)
.void
Variant ofsend()
that ignores the result of the operation.void
sendAndForget
(Buffer body) Variant ofsend(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.void
sendAndForget
(ReadStream<Buffer> body) Variant ofsend(io.vertx.mutiny.core.streams.ReadStream)
that ignores the result of the operation.void
sendAndForget
(String body) Variant ofsend(String)
that ignores the result of the operation.void
sendAndForget
(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) int
streamId()
toString()
trailers()
io.smallrye.mutiny.Uni<Void>
Same as but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
Same aswrite(io.vertx.mutiny.core.buffer.Buffer)
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
Same aswrite(io.vertx.mutiny.core.buffer.Buffer)
but with anhandler
called 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)
.void
writeAndForget
(Buffer data) Variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.void
writeAndForget
(String chunk) Variant ofwrite(String)
that ignores the result of the operation.void
writeAndForget
(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 anhandler
called when the operation completeswriteEarlyHintsAndAwait
(MultiMap headers) Blocking variant ofwriteEarlyHints(io.vertx.mutiny.core.MultiMap)
.void
writeEarlyHintsAndForget
(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:
getDelegate
in interfaceMutinyDelegate
- Specified by:
getDelegate
in interfaceStreamBase
- Specified by:
getDelegate
in 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 anhandler
called 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:
write
in interfaceWriteStream<Buffer>
- Parameters:
data
-- Returns:
- the
uni
firing 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:
writeAndAwait
in 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:
writeAndForget
in interfaceWriteStream<Buffer>
- Parameters:
data
-
-
end
Same asend()
but with anhandler
called 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:
end
in interfaceWriteStream<Buffer>
- Returns:
- the
uni
firing 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:
endAndAwait
in 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:
endAndForget
in interfaceWriteStream<Buffer>
-
writeQueueFull
public boolean writeQueueFull()- Specified by:
writeQueueFull
in interfaceWriteStream<Buffer>
- Returns:
true
if write queue is full
-
exceptionHandler
- Specified by:
exceptionHandler
in interfaceStreamBase
- Specified by:
exceptionHandler
in interfaceWriteStream<Buffer>
- Parameters:
handler
- the exception handler- Returns:
-
setWriteQueueMaxSize
- Specified by:
setWriteQueueMaxSize
in 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:
drainHandler
in interfaceWriteStream<Buffer>
- Parameters:
handler
- the handler- Returns:
-
getStatusCode
public int getStatusCode()- Returns:
- the HTTP status code of the response. The default is
200
representingOK
.
-
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 anhandler
called 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
uni
firing 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 anhandler
called 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
uni
firing 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 anhandler
called 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
uni
firing 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 anhandler
called 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
uni
firing 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 anhandler
called 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
uni
firing 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 anhandler
called 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:
end
in interfaceWriteStream<Buffer>
- Parameters:
chunk
-- Returns:
- the
uni
firing 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:
endAndAwait
in 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:
endAndForget
in 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
uni
firing 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
uni
firing 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
uni
firing 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
HttpHeaders
is 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
uni
firing 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
HttpHeaders
is 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
uni
firing 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
uni
firing 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
uni
firing 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
uni
firing 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 @Deprecated public io.smallrye.mutiny.Uni<HttpServerResponse> push(io.vertx.core.http.HttpMethod method, String host, String path) Deprecated.instead use#push(HttpMethod, HostAndPort, String, Handler)
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
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
pushAndAwait
@Deprecated public HttpServerResponse pushAndAwait(io.vertx.core.http.HttpMethod method, String host, String path) Deprecated.instead use#push(HttpMethod, HostAndPort, String, Handler)
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
@Deprecated public HttpServerResponse pushAndForget(io.vertx.core.http.HttpMethod method, String host, String path) Deprecated.instead use#push(HttpMethod, HostAndPort, String, Handler)
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, HostAndPort 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
uni
firing 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 host, String path) Blocking variant ofpush(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,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, HostAndPort host, String path) Variant ofpush(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,String)
that ignores the result of the operation.This method subscribes on the result of
push(HttpMethod,io.vertx.mutiny.core.net.HostAndPort,String)
, 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)
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
uni
firing 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
uni
firing 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 @Deprecated public io.smallrye.mutiny.Uni<HttpServerResponse> push(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Deprecated.Push a response to the client. Thehandler
will 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. Thehandler
may 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
- the authority of the promised requestpath
- the path of the promised requestheaders
- the headers of the promised request- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
pushAndAwait
@Deprecated public HttpServerResponse pushAndAwait(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Deprecated.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
- the authority of the promised requestpath
- the path of the promised requestheaders
- the headers of the promised request- Returns:
- the HttpServerResponse instance produced by the operation.
-
pushAndForget
@Deprecated public HttpServerResponse pushAndForget(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers) Deprecated.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
- the authority of the promised requestpath
- 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) Push a response to the client. Thehandler
will 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. Thehandler
may 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 requestauthority
- the authority of the promised requestpath
- the path of the promised requestheaders
- the headers of the promised request- Returns:
- the
uni
firing 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
- the method of the promised requestauthority
- the authority of the promised requestpath
- 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, 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
- the method of the promised requestauthority
- the authority of the promised requestpath
- the path of the promised requestheaders
- the headers of the promised request- 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:
true
when 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