Class HttpServerResponse
- java.lang.Object
-
- io.vertx.mutiny.core.http.HttpServerResponse
-
- All Implemented Interfaces:
StreamBase
,WriteStream<Buffer>
public class HttpServerResponse extends Object implements WriteStream<Buffer>
Represents a server-side HTTP response.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
NOTE: This class has been automatically generated from theWriteStream
so it can be used withPipe
to pipe data with flow control.original
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<HttpServerResponse>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description HttpServerResponse(io.vertx.core.http.HttpServerResponse delegate)
HttpServerResponse(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpServerResponse
addCookie(Cookie cookie)
HttpServerResponse
bodyEndHandler(Runnable handler)
long
bytesWritten()
void
close()
boolean
closed()
HttpServerResponse
closeHandler(Runnable handler)
HttpServerResponse
drainHandler(Runnable handler)
io.smallrye.mutiny.Uni<Void>
end()
Same asend()
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
end(Buffer chunk)
Same asend()
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
end(String chunk)
Same asend()
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
end(String chunk, String enc)
Same asend()
but with anhandler
called when the operation completesVoid
endAndAwait()
Blocking variant ofWriteStream.end()
.Void
endAndAwait(Buffer chunk)
Blocking variant ofend(io.vertx.mutiny.core.buffer.Buffer)
.Void
endAndAwait(String chunk)
Blocking variant ofend(String)
.Void
endAndAwait(String chunk, String enc)
Blocking variant ofend(String,String)
.void
endAndForget()
Variant ofWriteStream.end()
that ignores the result of the operation.void
endAndForget(Buffer chunk)
Variant ofend(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()
HttpServerResponse
endHandler(Runnable handler)
boolean
equals(Object o)
HttpServerResponse
exceptionHandler(Consumer<Throwable> handler)
io.vertx.core.http.HttpServerResponse
getDelegate()
int
getStatusCode()
String
getStatusMessage()
int
hashCode()
MultiMap
headers()
HttpServerResponse
headersEndHandler(Runnable handler)
boolean
headWritten()
boolean
isChunked()
static HttpServerResponse
newInstance(io.vertx.core.http.HttpServerResponse arg)
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.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.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.io.smallrye.mutiny.Uni<HttpServerResponse>
push(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers)
Push a response to the client.HttpServerResponse
pushAndAwait(io.vertx.core.http.HttpMethod method, String path)
Blocking variant ofpush(HttpMethod,String)
.HttpServerResponse
pushAndAwait(io.vertx.core.http.HttpMethod method, String path, MultiMap headers)
Blocking variant ofpush(HttpMethod,String,io.vertx.mutiny.core.MultiMap)
.HttpServerResponse
pushAndAwait(io.vertx.core.http.HttpMethod method, String host, String path)
Blocking variant ofpush(HttpMethod,String,String)
.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)
.HttpServerResponse
pushAndForget(io.vertx.core.http.HttpMethod method, String path)
Variant ofpush(HttpMethod,String)
that ignores the result of the operation.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.HttpServerResponse
pushAndForget(io.vertx.core.http.HttpMethod method, String host, String path)
Variant ofpush(HttpMethod,String,String)
that ignores the result of the operation.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.HttpServerResponse
putHeader(CharSequence name, CharSequence value)
HttpServerResponse
putHeader(CharSequence name, Iterable<CharSequence> values)
HttpServerResponse
putHeader(String name, Iterable<String> values)
HttpServerResponse
putHeader(String name, String value)
HttpServerResponse
putTrailer(CharSequence name, CharSequence value)
HttpServerResponse
putTrailer(CharSequence name, Iterable<CharSequence> value)
HttpServerResponse
putTrailer(String name, Iterable<String> values)
HttpServerResponse
putTrailer(String name, String value)
Cookie
removeCookie(String name)
Cookie
removeCookie(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(Buffer body)
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(String body)
Send the request with a stringbody
.io.smallrye.mutiny.Uni<Void>
send(org.reactivestreams.Publisher<Buffer> body)
Send the request with a streambody
.Void
sendAndAwait()
Blocking variant ofsend()
.Void
sendAndAwait(Buffer body)
Blocking variant ofsend(io.vertx.mutiny.core.buffer.Buffer)
.Void
sendAndAwait(ReadStream<Buffer> body)
Blocking variant ofio.vertx.mutiny.core.http.HttpServerResponse#send(io.vertx.mutiny.core.streams.ReadStream
.) Void
sendAndAwait(String body)
Blocking variant ofsend(String)
.Void
sendAndAwait(org.reactivestreams.Publisher<Buffer> body)
Blocking variant ofsend(Publisher<Buffer>)
.void
sendAndForget()
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 ofio.vertx.mutiny.core.http.HttpServerResponse#send(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(org.reactivestreams.Publisher<Buffer> body)
Variant ofsend(Publisher<Buffer>)
that ignores the result of the operation.io.smallrye.mutiny.Uni<Void>
sendFile(String filename)
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>
sendFile(String filename, long offset)
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>
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.Void
sendFileAndAwait(String filename)
Blocking variant ofsendFile(String)
.Void
sendFileAndAwait(String filename, long offset)
Blocking variant ofsendFile(String,long)
.Void
sendFileAndAwait(String filename, long offset, long length)
Blocking variant ofsendFile(String,long,long)
.HttpServerResponse
sendFileAndForget(String filename)
Variant ofsendFile(String)
that ignores the result of the operation.HttpServerResponse
sendFileAndForget(String filename, long offset)
Variant ofsendFile(String,long)
that ignores the result of the operation.HttpServerResponse
sendFileAndForget(String filename, long offset, long length)
Variant ofsendFile(String,long,long)
that ignores the result of the operation.HttpServerResponse
setChunked(boolean chunked)
HttpServerResponse
setStatusCode(int statusCode)
HttpServerResponse
setStatusMessage(String statusMessage)
HttpServerResponse
setStreamPriority(io.vertx.core.http.StreamPriority streamPriority)
HttpServerResponse
setWriteQueueMaxSize(int maxSize)
int
streamId()
String
toString()
WriteStreamSubscriber<Buffer>
toSubscriber()
MultiMap
trailers()
io.smallrye.mutiny.Uni<Void>
write(Buffer data)
Same as but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
write(String chunk)
Same aswrite(io.vertx.mutiny.core.buffer.Buffer)
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
write(String chunk, String enc)
Same aswrite(io.vertx.mutiny.core.buffer.Buffer)
but with anhandler
called when the operation completesVoid
writeAndAwait(Buffer data)
Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer)
.Void
writeAndAwait(String chunk)
Blocking variant ofwrite(String)
.Void
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.HttpServerResponse
writeContinue()
HttpServerResponse
writeCustomFrame(int type, int flags, Buffer payload)
HttpServerResponse
writeCustomFrame(HttpFrame frame)
boolean
writeQueueFull()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<HttpServerResponse> __TYPE_ARG
-
-
Constructor Detail
-
HttpServerResponse
public HttpServerResponse(io.vertx.core.http.HttpServerResponse delegate)
-
HttpServerResponse
public HttpServerResponse(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.core.http.HttpServerResponse getDelegate()
- Specified by:
getDelegate
in interfaceStreamBase
- Specified by:
getDelegate
in interfaceWriteStream<Buffer>
-
toSubscriber
public WriteStreamSubscriber<Buffer> toSubscriber()
-
write
public io.smallrye.mutiny.Uni<Void> write(Buffer data)
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
public Void writeAndAwait(Buffer data)
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
public 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.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
public io.smallrye.mutiny.Uni<Void> 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
public Void 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
public HttpServerResponse exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandler
in interfaceStreamBase
- Specified by:
exceptionHandler
in interfaceWriteStream<Buffer>
- Parameters:
handler
- the exception handler- Returns:
-
setWriteQueueMaxSize
public HttpServerResponse setWriteQueueMaxSize(int maxSize)
- 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
public HttpServerResponse drainHandler(Runnable handler)
- 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
public HttpServerResponse setStatusCode(int statusCode)
- Parameters:
statusCode
-- Returns:
- a reference to this, so the API can be used fluently
-
getStatusMessage
public String 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
public HttpServerResponse setStatusMessage(String statusMessage)
- Parameters:
statusMessage
-- Returns:
- a reference to this, so the API can be used fluently
-
setChunked
public HttpServerResponse setChunked(boolean chunked)
- Parameters:
chunked
-- Returns:
- a reference to this, so the API can be used fluently
-
isChunked
public boolean isChunked()
- Returns:
- is the response chunked?
-
headers
public MultiMap headers()
- Returns:
- The HTTP headers
-
putHeader
public HttpServerResponse putHeader(String name, String value)
- Parameters:
name
- the header namevalue
- the header value.- Returns:
- a reference to this, so the API can be used fluently
-
trailers
public MultiMap trailers()
- Returns:
- The HTTP trailers
-
putTrailer
public HttpServerResponse putTrailer(String name, String value)
- Parameters:
name
- the trailer namevalue
- the trailer value- Returns:
- a reference to this, so the API can be used fluently
-
closeHandler
public HttpServerResponse closeHandler(Runnable handler)
- Parameters:
handler
- the handler- Returns:
-
endHandler
public HttpServerResponse endHandler(Runnable handler)
- Parameters:
handler
- the handler- Returns:
-
write
public io.smallrye.mutiny.Uni<Void> write(String chunk, String enc)
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
public Void writeAndAwait(String chunk, String enc)
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
public void writeAndForget(String chunk, String enc)
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
public io.smallrye.mutiny.Uni<Void> write(String chunk)
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
public Void writeAndAwait(String chunk)
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
public void writeAndForget(String chunk)
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
public HttpServerResponse writeContinue()
- Returns:
- a reference to this, so the API can be used fluently
-
end
public io.smallrye.mutiny.Uni<Void> end(String chunk)
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
public Void endAndAwait(String chunk)
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
public void endAndForget(String chunk)
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
public io.smallrye.mutiny.Uni<Void> end(String chunk, String enc)
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
public Void endAndAwait(String chunk, String enc)
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
public void endAndForget(String chunk, String enc)
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
public io.smallrye.mutiny.Uni<Void> end(Buffer chunk)
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
public Void endAndAwait(Buffer chunk)
Blocking variant ofend(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
public void endAndForget(Buffer chunk)
Variant ofend(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.This method subscribes on the result of
end(io.vertx.mutiny.core.buffer.Buffer)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromend(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
public io.smallrye.mutiny.Uni<Void> 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
public Void 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
public io.smallrye.mutiny.Uni<Void> send(String body)
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
public Void sendAndAwait(String body)
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
public void sendAndForget(String body)
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
public io.smallrye.mutiny.Uni<Void> send(Buffer body)
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
public Void sendAndAwait(Buffer body)
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
public void sendAndForget(Buffer body)
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
public io.smallrye.mutiny.Uni<Void> send(ReadStream<Buffer> body)
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
public Void sendAndAwait(ReadStream<Buffer> body)
Blocking variant ofio.vertx.mutiny.core.http.HttpServerResponse#send(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
public void sendAndForget(ReadStream<Buffer> body)
Variant ofio.vertx.mutiny.core.http.HttpServerResponse#send(io.vertx.mutiny.core.streams.ReadStream
that ignores the result of the operation.) This method subscribes on the result of
io.vertx.mutiny.core.http.HttpServerResponse#send(io.vertx.mutiny.core.streams.ReadStream
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from) io.vertx.mutiny.core.http.HttpServerResponse#send(io.vertx.mutiny.core.streams.ReadStream
but you don't need to compose it with other operations.) - Parameters:
body
-
-
send
public io.smallrye.mutiny.Uni<Void> send(org.reactivestreams.Publisher<Buffer> body)
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
public Void sendAndAwait(org.reactivestreams.Publisher<Buffer> body)
Blocking variant ofsend(Publisher<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
public void sendAndForget(org.reactivestreams.Publisher<Buffer> body)
Variant ofsend(Publisher<Buffer>)
that ignores the result of the operation.This method subscribes on the result of
send(Publisher<Buffer>)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsend(Publisher<Buffer>)
but you don't need to compose it with other operations.- Parameters:
body
-
-
sendFile
public io.smallrye.mutiny.Uni<Void> sendFile(String filename)
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
public Void sendFileAndAwait(String filename)
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
public HttpServerResponse sendFileAndForget(String filename)
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
public io.smallrye.mutiny.Uni<Void> sendFile(String filename, long offset)
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
public Void sendFileAndAwait(String filename, long offset)
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
public HttpServerResponse sendFileAndForget(String filename, long offset)
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
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
public Void sendFileAndAwait(String filename, long offset, long length)
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
public HttpServerResponse sendFileAndForget(String filename, long offset, long length)
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
public void close()
-
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
public HttpServerResponse headersEndHandler(Runnable handler)
- Parameters:
handler
- the handler- Returns:
-
bodyEndHandler
public HttpServerResponse bodyEndHandler(Runnable handler)
- 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
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
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 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
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
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
public HttpServerResponse pushAndAwait(io.vertx.core.http.HttpMethod method, String path)
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
public HttpServerResponse pushAndForget(io.vertx.core.http.HttpMethod method, String path)
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
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. 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 host 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, 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
- the host 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, 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
- the host 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
public HttpServerResponse writeCustomFrame(int type, int flags, Buffer payload)
- 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
public HttpServerResponse writeCustomFrame(HttpFrame frame)
- Parameters:
frame
- the frame to write- Returns:
- the instance of HttpServerResponse to chain method calls.
-
setStreamPriority
public HttpServerResponse setStreamPriority(io.vertx.core.http.StreamPriority streamPriority)
- Parameters:
streamPriority
- the priority for this request's stream- Returns:
- the instance of HttpServerResponse to chain method calls.
-
addCookie
public HttpServerResponse addCookie(Cookie cookie)
- Parameters:
cookie
- the cookie- Returns:
- a reference to this, so the API can be used fluently
-
removeCookie
public Cookie removeCookie(String name)
- Parameters:
name
- the name of the cookie- Returns:
- the cookie, if it existed, or null
-
removeCookie
public Cookie removeCookie(String name, boolean invalidate)
- Parameters:
name
- the name of the cookieinvalidate
-- Returns:
- the cookie, if it existed, or null
-
putHeader
public HttpServerResponse putHeader(CharSequence name, CharSequence value)
- Parameters:
name
-value
-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putHeader
public HttpServerResponse putHeader(String name, Iterable<String> values)
- Parameters:
name
-values
-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putHeader
public HttpServerResponse putHeader(CharSequence name, Iterable<CharSequence> values)
- Parameters:
name
-values
-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putTrailer
public HttpServerResponse putTrailer(CharSequence name, CharSequence value)
- Parameters:
name
-value
-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putTrailer
public HttpServerResponse putTrailer(String name, Iterable<String> values)
- Parameters:
name
-values
-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
putTrailer
public HttpServerResponse putTrailer(CharSequence name, Iterable<CharSequence> value)
- Parameters:
name
-value
-- Returns:
- the instance of HttpServerResponse to chain method calls.
-
newInstance
public static HttpServerResponse newInstance(io.vertx.core.http.HttpServerResponse arg)
-
-