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
HttpServerRequestthat.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 theWriteStreamso it can be used withPipeto pipe data with flow control.originalnon 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 HttpServerResponseaddCookie(Cookie cookie)HttpServerResponsebodyEndHandler(Runnable handler)longbytesWritten()voidclose()booleanclosed()HttpServerResponsecloseHandler(Runnable handler)HttpServerResponsedrainHandler(Runnable handler)io.smallrye.mutiny.Uni<Void>end()Same asend()but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>end(Buffer chunk)Same asend()but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>end(String chunk)Same asend()but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>end(String chunk, String enc)Same asend()but with anhandlercalled when the operation completesVoidendAndAwait()Blocking variant ofWriteStream.end().VoidendAndAwait(Buffer chunk)Blocking variant ofend(io.vertx.mutiny.core.buffer.Buffer).VoidendAndAwait(String chunk)Blocking variant ofend(String).VoidendAndAwait(String chunk, String enc)Blocking variant ofend(String,String).voidendAndForget()Variant ofWriteStream.end()that ignores the result of the operation.voidendAndForget(Buffer chunk)Variant ofend(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()HttpServerResponseendHandler(Runnable handler)booleanequals(Object o)HttpServerResponseexceptionHandler(Consumer<Throwable> handler)io.vertx.core.http.HttpServerResponsegetDelegate()intgetStatusCode()StringgetStatusMessage()inthashCode()MultiMapheaders()HttpServerResponseheadersEndHandler(Runnable handler)booleanheadWritten()booleanisChunked()static HttpServerResponsenewInstance(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.HttpServerResponsepushAndAwait(io.vertx.core.http.HttpMethod method, String path)Blocking variant ofpush(HttpMethod,String).HttpServerResponsepushAndAwait(io.vertx.core.http.HttpMethod method, String path, MultiMap headers)Blocking variant ofpush(HttpMethod,String,io.vertx.mutiny.core.MultiMap).HttpServerResponsepushAndAwait(io.vertx.core.http.HttpMethod method, String host, String path)Blocking variant ofpush(HttpMethod,String,String).HttpServerResponsepushAndAwait(io.vertx.core.http.HttpMethod method, String host, String path, MultiMap headers)Blocking variant ofpush(HttpMethod,String,String,io.vertx.mutiny.core.MultiMap).HttpServerResponsepushAndForget(io.vertx.core.http.HttpMethod method, String path)Variant ofpush(HttpMethod,String)that ignores the result of the operation.HttpServerResponsepushAndForget(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.HttpServerResponsepushAndForget(io.vertx.core.http.HttpMethod method, String host, String path)Variant ofpush(HttpMethod,String,String)that ignores the result of the operation.HttpServerResponsepushAndForget(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.HttpServerResponseputHeader(CharSequence name, CharSequence value)HttpServerResponseputHeader(CharSequence name, Iterable<CharSequence> values)HttpServerResponseputHeader(String name, Iterable<String> values)HttpServerResponseputHeader(String name, String value)HttpServerResponseputTrailer(CharSequence name, CharSequence value)HttpServerResponseputTrailer(CharSequence name, Iterable<CharSequence> value)HttpServerResponseputTrailer(String name, Iterable<String> values)HttpServerResponseputTrailer(String name, String value)CookieremoveCookie(String name)CookieremoveCookie(String name, boolean invalidate)CookieremoveCookie(String name, String domain, String path)CookieremoveCookie(String name, String domain, String path, boolean invalidate)Set<Cookie>removeCookies(String name)Set<Cookie>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(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.VoidsendAndAwait()Blocking variant ofsend().VoidsendAndAwait(Buffer body)Blocking variant ofsend(io.vertx.mutiny.core.buffer.Buffer).VoidsendAndAwait(ReadStream<Buffer> body)Blocking variant ofio.vertx.mutiny.core.http.HttpServerResponse#send(io.vertx.mutiny.core.streams.ReadStream.) VoidsendAndAwait(String body)Blocking variant ofsend(String).VoidsendAndAwait(org.reactivestreams.Publisher<Buffer> body)Blocking variant ofsend(Publisher<Buffer>).voidsendAndForget()Variant 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 ofio.vertx.mutiny.core.http.HttpServerResponse#send(io.vertx.mutiny.core.streams.ReadStreamthat ignores the result of the operation.) voidsendAndForget(String body)Variant ofsend(String)that ignores the result of the operation.voidsendAndForget(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.VoidsendFileAndAwait(String filename)Blocking variant ofsendFile(String).VoidsendFileAndAwait(String filename, long offset)Blocking variant ofsendFile(String,long).VoidsendFileAndAwait(String filename, long offset, long length)Blocking variant ofsendFile(String,long,long).HttpServerResponsesendFileAndForget(String filename)Variant ofsendFile(String)that ignores the result of the operation.HttpServerResponsesendFileAndForget(String filename, long offset)Variant ofsendFile(String,long)that ignores the result of the operation.HttpServerResponsesendFileAndForget(String filename, long offset, long length)Variant ofsendFile(String,long,long)that ignores the result of the operation.HttpServerResponsesetChunked(boolean chunked)HttpServerResponsesetStatusCode(int statusCode)HttpServerResponsesetStatusMessage(String statusMessage)HttpServerResponsesetStreamPriority(io.vertx.core.http.StreamPriority streamPriority)HttpServerResponsesetWriteQueueMaxSize(int maxSize)intstreamId()StringtoString()WriteStreamSubscriber<Buffer>toSubscriber()MultiMaptrailers()io.smallrye.mutiny.Uni<Void>write(Buffer data)Same as but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>write(String chunk)Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesio.smallrye.mutiny.Uni<Void>write(String chunk, String enc)Same aswrite(io.vertx.mutiny.core.buffer.Buffer)but with anhandlercalled when the operation completesVoidwriteAndAwait(Buffer data)Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#write(io.vertx.mutiny.core.buffer.Buffer).VoidwriteAndAwait(String chunk)Blocking variant ofwrite(String).VoidwriteAndAwait(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.HttpServerResponsewriteContinue()HttpServerResponsewriteCustomFrame(int type, int flags, Buffer payload)HttpServerResponsewriteCustomFrame(HttpFrame frame)booleanwriteQueueFull()
-
-
-
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:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<Buffer>
-
toSubscriber
@CheckReturnValue public WriteStreamSubscriber<Buffer> toSubscriber()
-
write
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> write(Buffer data)
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
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:
writeAndAwaitin 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:
writeAndForgetin interfaceWriteStream<Buffer>- Parameters:
data-
-
end
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> 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
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:
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
public HttpServerResponse exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<Buffer>- Parameters:
handler- the exception handler- Returns:
-
setWriteQueueMaxSize
public HttpServerResponse setWriteQueueMaxSize(int maxSize)
- 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
public HttpServerResponse drainHandler(Runnable handler)
- 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
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
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> write(String chunk, String enc)
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
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
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> write(String chunk)
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
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
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> end(String chunk)
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
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
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> end(String chunk, String enc)
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
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
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> end(Buffer chunk)
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
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:
endAndAwaitin 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:
endAndForgetin interfaceWriteStream<Buffer>- Parameters:
chunk-
-
send
@CheckReturnValue 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
unifiring 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
@CheckReturnValue 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
unifiring 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
@CheckReturnValue 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
unifiring 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
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> send(ReadStream<Buffer> body)
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
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.ReadStreamthat 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.ReadStreambut you don't need to compose it with other operations.) - Parameters:
body-
-
send
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> send(org.reactivestreams.Publisher<Buffer> body)
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
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
@CheckReturnValue 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
unifiring 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
@CheckReturnValue 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
unifiring 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
@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
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
@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
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
@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- the host of the promised requestpath- 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- 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:
truewhen 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
-
removeCookies
public Set<Cookie> removeCookies(String name)
- Parameters:
name- the name of the cookie- Returns:
- a read only set of affected cookies, if they existed, or an empty set.
-
removeCookies
public Set<Cookie> removeCookies(String name, boolean invalidate)
- 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
public Cookie removeCookie(String name, String domain, String path)
- 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
public Cookie removeCookie(String name, String domain, String path, boolean invalidate)
- 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
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)
-
-