Class HttpConnection
- java.lang.Object
-
- io.vertx.mutiny.core.http.HttpConnection
-
public class HttpConnection extends Object
Represents an HTTP connection. HTTP/1.x connection provides an limited implementation, the following methods are implemented:close()
closeHandler(java.lang.Runnable)
exceptionHandler(java.util.function.Consumer<java.lang.Throwable>)
original
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<HttpConnection>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description HttpConnection(io.vertx.core.http.HttpConnection delegate)
HttpConnection(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.smallrye.mutiny.Uni<Void>
close()
Close the connection and all the currently active streams.Void
closeAndAwait()
Blocking variant ofclose()
.void
closeAndForget()
Variant ofclose()
that ignores the result of the operation.HttpConnection
closeHandler(Runnable handler)
boolean
equals(Object o)
HttpConnection
exceptionHandler(Consumer<Throwable> handler)
io.vertx.core.http.HttpConnection
getDelegate()
int
getWindowSize()
HttpConnection
goAway(long errorCode)
HttpConnection
goAway(long errorCode, int lastStreamId)
HttpConnection
goAway(long errorCode, int lastStreamId, Buffer debugData)
HttpConnection
goAwayHandler(Consumer<io.vertx.core.http.GoAway> handler)
int
hashCode()
String
indicatedServerName()
boolean
isSsl()
SocketAddress
localAddress()
SocketAddress
localAddress(boolean real)
static HttpConnection
newInstance(io.vertx.core.http.HttpConnection arg)
io.smallrye.mutiny.Uni<Buffer>
ping(Buffer data)
Send a frame to the remote endpoint.Buffer
pingAndAwait(Buffer data)
Blocking variant ofping(io.vertx.mutiny.core.buffer.Buffer)
.HttpConnection
pingAndForget(Buffer data)
Variant ofping(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.HttpConnection
pingHandler(Consumer<Buffer> handler)
SocketAddress
remoteAddress()
SocketAddress
remoteAddress(boolean real)
io.vertx.core.http.Http2Settings
remoteSettings()
HttpConnection
remoteSettingsHandler(Consumer<io.vertx.core.http.Http2Settings> handler)
io.vertx.core.http.Http2Settings
settings()
HttpConnection
setWindowSize(int windowSize)
io.smallrye.mutiny.Uni<Void>
shutdown()
Initiate a graceful connection shutdown, the connection is taken out of service and closed when all current requests are processed, otherwise after 30 seconds the connection will be closed.io.smallrye.mutiny.Uni<Void>
shutdown(long timeout)
Likeshutdown()
but with a specifictimeout
in milliseconds.Void
shutdownAndAwait()
Blocking variant ofshutdown()
.Void
shutdownAndAwait(long timeout)
Blocking variant ofshutdown(long)
.void
shutdownAndForget()
Variant ofshutdown()
that ignores the result of the operation.void
shutdownAndForget(long timeout)
Variant ofshutdown(long)
that ignores the result of the operation.HttpConnection
shutdownHandler(Runnable handler)
SSLSession
sslSession()
String
toString()
io.smallrye.mutiny.Uni<Void>
updateSettings(io.vertx.core.http.Http2Settings settings)
Send to the remote endpoint an update of this endpoint settingsVoid
updateSettingsAndAwait(io.vertx.core.http.Http2Settings settings)
Blocking variant ofupdateSettings(Http2Settings)
.HttpConnection
updateSettingsAndForget(io.vertx.core.http.Http2Settings settings)
Variant ofupdateSettings(Http2Settings)
that ignores the result of the operation.
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<HttpConnection> __TYPE_ARG
-
-
Constructor Detail
-
HttpConnection
public HttpConnection(io.vertx.core.http.HttpConnection delegate)
-
HttpConnection
public HttpConnection(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.core.http.HttpConnection getDelegate()
-
getWindowSize
public int getWindowSize()
- Returns:
- the current connection window size or
-1
for HTTP/1.x
-
setWindowSize
public HttpConnection setWindowSize(int windowSize)
- Parameters:
windowSize
- the new window size- Returns:
- a reference to this, so the API can be used fluently
-
goAway
public HttpConnection goAway(long errorCode)
- Parameters:
errorCode
-- Returns:
- the instance of HttpConnection to chain method calls.
-
goAway
public HttpConnection goAway(long errorCode, int lastStreamId)
- Parameters:
errorCode
-lastStreamId
-- Returns:
- the instance of HttpConnection to chain method calls.
-
goAway
public HttpConnection goAway(long errorCode, int lastStreamId, Buffer debugData)
- Parameters:
errorCode
- the error codelastStreamId
- the last stream iddebugData
- additional debug data sent to the remote endpoint- Returns:
- a reference to this, so the API can be used fluently
-
goAwayHandler
public HttpConnection goAwayHandler(Consumer<io.vertx.core.http.GoAway> handler)
- Parameters:
handler
- the handler- Returns:
-
shutdownHandler
public HttpConnection shutdownHandler(Runnable handler)
- Parameters:
handler
- the handler- Returns:
-
shutdown
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> shutdown()
Initiate a graceful connection shutdown, the connection is taken out of service and closed when all current requests are processed, otherwise after 30 seconds the connection will be closed. Client connection are immediately removed from the pool.- HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close
- HTTP/1.x client connection supports this feature
- HTTP/1.x server connections do not support this feature
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.
-
shutdownAndAwait
public Void shutdownAndAwait()
Blocking variant ofshutdown()
.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.
-
shutdownAndForget
public void shutdownAndForget()
Variant ofshutdown()
that ignores the result of the operation.This method subscribes on the result of
shutdown()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromshutdown()
but you don't need to compose it with other operations.
-
shutdown
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> shutdown(long timeout)
Likeshutdown()
but with a specifictimeout
in milliseconds.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
timeout
-- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
shutdownAndAwait
public Void shutdownAndAwait(long timeout)
Blocking variant ofshutdown(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:
timeout
-- Returns:
- the Void instance produced by the operation.
-
shutdownAndForget
public void shutdownAndForget(long timeout)
Variant ofshutdown(long)
that ignores the result of the operation.This method subscribes on the result of
shutdown(long)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromshutdown(long)
but you don't need to compose it with other operations.- Parameters:
timeout
-
-
closeHandler
public HttpConnection closeHandler(Runnable handler)
- Parameters:
handler
- the handler to be notified- Returns:
-
close
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
Close the connection and all the currently active streams. An HTTP/2 connection will send a frame before.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.
-
closeAndAwait
public Void closeAndAwait()
Blocking variant ofclose()
.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.
-
closeAndForget
public void closeAndForget()
-
settings
public io.vertx.core.http.Http2Settings settings()
- Returns:
- the latest server settings acknowledged by the remote endpoint - this is not implemented for HTTP/1.x
-
updateSettings
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> updateSettings(io.vertx.core.http.Http2Settings settings)
Send to the remote endpoint an update of this endpoint settings ThecompletionHandler
will be notified when the remote endpoint has acknowledged the settings. This is not implemented for HTTP/1.x.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
settings
- the new settings- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
updateSettingsAndAwait
public Void updateSettingsAndAwait(io.vertx.core.http.Http2Settings settings)
Blocking variant ofupdateSettings(Http2Settings)
.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:
settings
- the new settings- Returns:
- the Void instance produced by the operation.
-
updateSettingsAndForget
public HttpConnection updateSettingsAndForget(io.vertx.core.http.Http2Settings settings)
Variant ofupdateSettings(Http2Settings)
that ignores the result of the operation.This method subscribes on the result of
updateSettings(Http2Settings)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromupdateSettings(Http2Settings)
but you don't need to compose it with other operations.- Parameters:
settings
- the new settings- Returns:
- the instance of HttpConnection to chain method calls.
-
remoteSettings
public io.vertx.core.http.Http2Settings remoteSettings()
- Returns:
- the current remote endpoint settings for this connection - this is not implemented for HTTP/1.x
-
remoteSettingsHandler
public HttpConnection remoteSettingsHandler(Consumer<io.vertx.core.http.Http2Settings> handler)
- Parameters:
handler
- the handler for remote endpoint settings- Returns:
-
ping
@CheckReturnValue public io.smallrye.mutiny.Uni<Buffer> ping(Buffer data)
Send a frame to the remote endpoint. This is not implemented for HTTP/1.x.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
data
- the 8 bytes data of the frame- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
pingAndAwait
public Buffer pingAndAwait(Buffer data)
Blocking variant ofping(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:
data
- the 8 bytes data of the frame- Returns:
- the Buffer instance produced by the operation.
-
pingAndForget
public HttpConnection pingAndForget(Buffer data)
Variant ofping(io.vertx.mutiny.core.buffer.Buffer)
that ignores the result of the operation.This method subscribes on the result of
ping(io.vertx.mutiny.core.buffer.Buffer)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromping(io.vertx.mutiny.core.buffer.Buffer)
but you don't need to compose it with other operations.- Parameters:
data
- the 8 bytes data of the frame- Returns:
- the instance of HttpConnection to chain method calls.
-
pingHandler
public HttpConnection pingHandler(Consumer<Buffer> handler)
- Parameters:
handler
- the handler to be called when a is received- Returns:
-
exceptionHandler
public HttpConnection exceptionHandler(Consumer<Throwable> handler)
- Parameters:
handler
- the handler- Returns:
-
remoteAddress
public SocketAddress remoteAddress()
- Returns:
- the remote address for this connection, possibly
null
(e.g a server bound on a domain socket). IfuseProxyProtocol
is set totrue
, the address returned will be of the actual connecting client.
-
remoteAddress
public SocketAddress remoteAddress(boolean real)
- Parameters:
real
-- Returns:
-
localAddress
public SocketAddress localAddress()
- Returns:
- the local address for this connection, possibly
null
(e.g a server bound on a domain socket) IfuseProxyProtocol
is set totrue
, the address returned will be of the proxy.
-
localAddress
public SocketAddress localAddress(boolean real)
- Parameters:
real
-- Returns:
-
isSsl
public boolean isSsl()
- Returns:
- true if this
HttpConnection
is encrypted via SSL/TLS.
-
indicatedServerName
public String indicatedServerName()
- Returns:
- the indicated server name
-
sslSession
public SSLSession sslSession()
- Returns:
- SSLSession associated with the underlying socket. Returns null if connection is not SSL.
-
newInstance
public static HttpConnection newInstance(io.vertx.core.http.HttpConnection arg)
-
-