/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.vertx.reactivex.core.http;
import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
Represents an HTTP connection.
HTTP/1.x connection provides an limited implementation, the following methods are implemented:
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* Represents an HTTP connection.
* <p/>
* HTTP/1.x connection provides an limited implementation, the following methods are implemented:
* <ul>
* <li>{@link io.vertx.reactivex.core.http.HttpConnection#close}</li>
* <li>{@link io.vertx.reactivex.core.http.HttpConnection#closeHandler}</li>
* <li>{@link io.vertx.reactivex.core.http.HttpConnection#exceptionHandler}</li>
* </ul>
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.core.http.HttpConnection original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.core.http.HttpConnection.class)
public class HttpConnection {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
HttpConnection that = (HttpConnection) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg<HttpConnection> __TYPE_ARG = new TypeArg<>( obj -> new HttpConnection((io.vertx.core.http.HttpConnection) obj),
HttpConnection::getDelegate
);
private final io.vertx.core.http.HttpConnection delegate;
public HttpConnection(io.vertx.core.http.HttpConnection delegate) {
this.delegate = delegate;
}
public HttpConnection(Object delegate) {
this.delegate = (io.vertx.core.http.HttpConnection)delegate;
}
public io.vertx.core.http.HttpConnection getDelegate() {
return delegate;
}
Returns: the current connection window size or -1
for HTTP/1.x
/**
* @return the current connection window size or <code>-1</code> for HTTP/1.x
*/
public int getWindowSize() {
int ret = delegate.getWindowSize();
return ret;
}
Update the current connection wide window size to a new size.
Increasing this value, gives better performance when several data streams are multiplexed
This is not implemented for HTTP/1.x.
Params: - windowSize – the new window size
Returns: a reference to this, so the API can be used fluently
/**
* Update the current connection wide window size to a new size.
* <p/>
* Increasing this value, gives better performance when several data streams are multiplexed
* <p/>
* This is not implemented for HTTP/1.x.
* @param windowSize the new window size
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection setWindowSize(int windowSize) {
delegate.setWindowSize(windowSize);
return this;
}
Like goAway
with a last stream id -1
which means to disallow any new stream creation.
Params: - errorCode –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpConnection#goAway} with a last stream id <code>-1</code> which means to disallow any new stream creation.
* @param errorCode
* @return
*/
public io.vertx.reactivex.core.http.HttpConnection goAway(long errorCode) {
delegate.goAway(errorCode);
return this;
}
Like goAway
with no buffer. Params: - errorCode –
- lastStreamId –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpConnection#goAway} with no buffer.
* @param errorCode
* @param lastStreamId
* @return
*/
public io.vertx.reactivex.core.http.HttpConnection goAway(long errorCode, int lastStreamId) {
delegate.goAway(errorCode, lastStreamId);
return this;
}
Send a go away frame to the remote endpoint of the connection.
- a frame is sent to the to the remote endpoint with the
errorCode
and debugData
- any stream created after the stream identified by
lastStreamId
will be closed
- for an is different than
0
when all the remaining streams are closed this connection will be closed automatically
This is not implemented for HTTP/1.x.
Params: - errorCode – the error code
- lastStreamId – the last stream id
- debugData – additional debug data sent to the remote endpoint
Returns: a reference to this, so the API can be used fluently
/**
* Send a go away frame to the remote endpoint of the connection.
* <p/>
* <ul>
* <li>a frame is sent to the to the remote endpoint with the <code>errorCode</code> and <code>debugData</code></li>
* <li>any stream created after the stream identified by <code>lastStreamId</code> will be closed</li>
* <li>for an is different than <code>0</code> when all the remaining streams are closed this connection will be closed automatically</li>
* </ul>
* <p/>
* This is not implemented for HTTP/1.x.
* @param errorCode the error code
* @param lastStreamId the last stream id
* @param debugData additional debug data sent to the remote endpoint
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection goAway(long errorCode, int lastStreamId, io.vertx.reactivex.core.buffer.Buffer debugData) {
delegate.goAway(errorCode, lastStreamId, debugData.getDelegate());
return this;
}
Set an handler called when a frame is received.
This is not implemented for HTTP/1.x.
Params: - handler – the handler
Returns: a reference to this, so the API can be used fluently
/**
* Set an handler called when a frame is received.
* <p/>
* This is not implemented for HTTP/1.x.
* @param handler the handler
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection goAwayHandler(Handler<io.vertx.core.http.GoAway> handler) {
delegate.goAwayHandler(handler);
return this;
}
Set an handler called when a frame has been sent or received and all connections are closed.
This is not implemented for HTTP/1.x.
Params: - handler – the handler
Returns: a reference to this, so the API can be used fluently
/**
* Set an handler called when a frame has been sent or received and all connections are closed.
* <p/>
* This is not implemented for HTTP/1.x.
* @param handler the handler
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection shutdownHandler(Handler<Void> handler) {
delegate.shutdownHandler(handler);
return this;
}
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
Params: - handler – the handler called when shutdown has completed
/**
* 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.
*
* <ul>
* <li>HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close</li>
* <li>HTTP/1.x client connection supports this feature</li>
* <li>HTTP/1.x server connections do not support this feature</li>
* </ul>
* @param handler the handler called when shutdown has completed
*/
public void shutdown(Handler<AsyncResult<Void>> handler) {
delegate.shutdown(handler);
}
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
/**
* 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.
*
* <ul>
* <li>HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close</li>
* <li>HTTP/1.x client connection supports this feature</li>
* <li>HTTP/1.x server connections do not support this feature</li>
* </ul>
*/
public void shutdown() {
shutdown(ar -> { });
}
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
Returns:
/**
* 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.
*
* <ul>
* <li>HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close</li>
* <li>HTTP/1.x client connection supports this feature</li>
* <li>HTTP/1.x server connections do not support this feature</li>
* </ul>
* @return
*/
public io.reactivex.Completable rxShutdown() {
return AsyncResultCompletable.toCompletable($handler -> {
shutdown($handler);
});
}
Like shutdown
but with a specific timeout
in milliseconds.
Params: - timeout –
- handler –
/**
* Like {@link io.vertx.reactivex.core.http.HttpConnection#shutdown} but with a specific <code>timeout</code> in milliseconds.
* @param timeout
* @param handler
*/
public void shutdown(long timeout, Handler<AsyncResult<Void>> handler) {
delegate.shutdown(timeout, handler);
}
Like shutdown
but with a specific timeout
in milliseconds.
Params: - timeout –
/**
* Like {@link io.vertx.reactivex.core.http.HttpConnection#shutdown} but with a specific <code>timeout</code> in milliseconds.
* @param timeout
*/
public void shutdown(long timeout) {
shutdown(timeout, ar -> { });
}
Like shutdown
but with a specific timeout
in milliseconds.
Params: - timeout –
Returns:
/**
* Like {@link io.vertx.reactivex.core.http.HttpConnection#shutdown} but with a specific <code>timeout</code> in milliseconds.
* @param timeout
* @return
*/
public io.reactivex.Completable rxShutdown(long timeout) {
return AsyncResultCompletable.toCompletable($handler -> {
shutdown(timeout, $handler);
});
}
Set a close handler. The handler will get notified when the connection is closed.
Params: - handler – the handler to be notified
Returns: a reference to this, so the API can be used fluently
/**
* Set a close handler. The handler will get notified when the connection is closed.
* @param handler the handler to be notified
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection closeHandler(Handler<Void> handler) {
delegate.closeHandler(handler);
return this;
}
Close the connection and all the currently active streams.
An HTTP/2 connection will send a frame before.
Params: - handler – the handler to be completed when the connection is closed
/**
* Close the connection and all the currently active streams.
* <p/>
* An HTTP/2 connection will send a frame before.
* @param handler the handler to be completed when the connection is closed
*/
public void close(Handler<AsyncResult<Void>> handler) {
delegate.close(handler);
}
Close the connection and all the currently active streams.
An HTTP/2 connection will send a frame before.
/**
* Close the connection and all the currently active streams.
* <p/>
* An HTTP/2 connection will send a frame before.
*/
public void close() {
close(ar -> { });
}
Close the connection and all the currently active streams.
An HTTP/2 connection will send a frame before.
Returns:
/**
* Close the connection and all the currently active streams.
* <p/>
* An HTTP/2 connection will send a frame before.
* @return
*/
public io.reactivex.Completable rxClose() {
return AsyncResultCompletable.toCompletable($handler -> {
close($handler);
});
}
Returns: the latest server settings acknowledged by the remote endpoint - this is not implemented for HTTP/1.x
/**
* @return the latest server settings acknowledged by the remote endpoint - this is not implemented for HTTP/1.x
*/
public io.vertx.core.http.Http2Settings settings() {
io.vertx.core.http.Http2Settings ret = delegate.settings();
return ret;
}
Send to the remote endpoint an update of this endpoint settings
The completionHandler
will be notified when the remote endpoint has acknowledged the settings.
This is not implemented for HTTP/1.x.
Params: - settings – the new settings
- completionHandler – the handler notified when the settings have been acknowledged by the remote endpoint
Returns: a reference to this, so the API can be used fluently
/**
* Send to the remote endpoint an update of this endpoint settings
* <p/>
* The <code>completionHandler</code> will be notified when the remote endpoint has acknowledged the settings.
* <p/>
* This is not implemented for HTTP/1.x.
* @param settings the new settings
* @param completionHandler the handler notified when the settings have been acknowledged by the remote endpoint
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection updateSettings(io.vertx.core.http.Http2Settings settings, Handler<AsyncResult<Void>> completionHandler) {
delegate.updateSettings(settings, completionHandler);
return this;
}
Send to the remote endpoint an update of this endpoint settings
The completionHandler
will be notified when the remote endpoint has acknowledged the settings.
This is not implemented for HTTP/1.x.
Params: - settings – the new settings
Returns: a reference to this, so the API can be used fluently
/**
* Send to the remote endpoint an update of this endpoint settings
* <p/>
* The <code>completionHandler</code> will be notified when the remote endpoint has acknowledged the settings.
* <p/>
* This is not implemented for HTTP/1.x.
* @param settings the new settings
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection updateSettings(io.vertx.core.http.Http2Settings settings) {
return
updateSettings(settings, ar -> { });
}
Send to the remote endpoint an update of this endpoint settings
The completionHandler
will be notified when the remote endpoint has acknowledged the settings.
This is not implemented for HTTP/1.x.
Params: - settings – the new settings
Returns: a reference to this, so the API can be used fluently
/**
* Send to the remote endpoint an update of this endpoint settings
* <p/>
* The <code>completionHandler</code> will be notified when the remote endpoint has acknowledged the settings.
* <p/>
* This is not implemented for HTTP/1.x.
* @param settings the new settings
* @return a reference to this, so the API can be used fluently
*/
public io.reactivex.Completable rxUpdateSettings(io.vertx.core.http.Http2Settings settings) {
return AsyncResultCompletable.toCompletable($handler -> {
updateSettings(settings, $handler);
});
}
Returns: the current remote endpoint settings for this connection - this is not implemented for HTTP/1.x
/**
* @return the current remote endpoint settings for this connection - this is not implemented for HTTP/1.x
*/
public io.vertx.core.http.Http2Settings remoteSettings() {
io.vertx.core.http.Http2Settings ret = delegate.remoteSettings();
return ret;
}
Set an handler that is called when remote endpoint Http2Settings
are updated.
This is not implemented for HTTP/1.x.
Params: - handler – the handler for remote endpoint settings
Returns: a reference to this, so the API can be used fluently
/**
* Set an handler that is called when remote endpoint {@link io.vertx.core.http.Http2Settings} are updated.
* <p/>
* This is not implemented for HTTP/1.x.
* @param handler the handler for remote endpoint settings
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection remoteSettingsHandler(Handler<io.vertx.core.http.Http2Settings> handler) {
delegate.remoteSettingsHandler(handler);
return this;
}
Send a frame to the remote endpoint.
This is not implemented for HTTP/1.x.
Params: - data – the 8 bytes data of the frame
- pongHandler – an async result handler notified with pong reply or the failure
Returns: a reference to this, so the API can be used fluently
/**
* Send a frame to the remote endpoint.
* <p/>
* This is not implemented for HTTP/1.x.
* @param data the 8 bytes data of the frame
* @param pongHandler an async result handler notified with pong reply or the failure
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection ping(io.vertx.reactivex.core.buffer.Buffer data, Handler<AsyncResult<io.vertx.reactivex.core.buffer.Buffer>> pongHandler) {
delegate.ping(data.getDelegate(), new Handler<AsyncResult<io.vertx.core.buffer.Buffer>>() {
public void handle(AsyncResult<io.vertx.core.buffer.Buffer> ar) {
if (ar.succeeded()) {
pongHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)ar.result())));
} else {
pongHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
Send a frame to the remote endpoint.
This is not implemented for HTTP/1.x.
Params: - data – the 8 bytes data of the frame
Returns: a reference to this, so the API can be used fluently
/**
* Send a frame to the remote endpoint.
* <p/>
* This is not implemented for HTTP/1.x.
* @param data the 8 bytes data of the frame
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection ping(io.vertx.reactivex.core.buffer.Buffer data) {
return
ping(data, ar -> { });
}
Send a frame to the remote endpoint.
This is not implemented for HTTP/1.x.
Params: - data – the 8 bytes data of the frame
Returns: a reference to this, so the API can be used fluently
/**
* Send a frame to the remote endpoint.
* <p/>
* This is not implemented for HTTP/1.x.
* @param data the 8 bytes data of the frame
* @return a reference to this, so the API can be used fluently
*/
public io.reactivex.Single<io.vertx.reactivex.core.buffer.Buffer> rxPing(io.vertx.reactivex.core.buffer.Buffer data) {
return AsyncResultSingle.toSingle($handler -> {
ping(data, $handler);
});
}
Set an handler notified when a frame is received from the remote endpoint.
This is not implemented for HTTP/1.x.
Params: - handler – the handler to be called when a is received
Returns: a reference to this, so the API can be used fluently
/**
* Set an handler notified when a frame is received from the remote endpoint.
* <p/>
* This is not implemented for HTTP/1.x.
* @param handler the handler to be called when a is received
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection pingHandler(Handler<io.vertx.reactivex.core.buffer.Buffer> handler) {
delegate.pingHandler(new Handler<io.vertx.core.buffer.Buffer>() {
public void handle(io.vertx.core.buffer.Buffer event) {
handler.handle(io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)event));
}
});
return this;
}
Set an handler called when a connection error happens
Params: - handler – the handler
Returns: a reference to this, so the API can be used fluently
/**
* Set an handler called when a connection error happens
* @param handler the handler
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.core.http.HttpConnection exceptionHandler(Handler<java.lang.Throwable> handler) {
delegate.exceptionHandler(handler);
return this;
}
Returns: the remote address for this connection, possibly null
(e.g a server bound on a domain socket). If useProxyProtocol
is set to true
, the address returned will be of the actual connecting client.
/**
* @return the remote address for this connection, possibly <code>null</code> (e.g a server bound on a domain socket). If <code>useProxyProtocol</code> is set to <code>true</code>, the address returned will be of the actual connecting client.
*/
public io.vertx.reactivex.core.net.SocketAddress remoteAddress() {
if (cached_0 != null) {
return cached_0;
}
io.vertx.reactivex.core.net.SocketAddress ret = io.vertx.reactivex.core.net.SocketAddress.newInstance((io.vertx.core.net.SocketAddress)delegate.remoteAddress());
cached_0 = ret;
return ret;
}
Returns: the local address for this connection, possibly null
(e.g a server bound on a domain socket) If useProxyProtocol
is set to true
, the address returned will be of the proxy.
/**
* @return the local address for this connection, possibly <code>null</code> (e.g a server bound on a domain socket) If <code>useProxyProtocol</code> is set to <code>true</code>, the address returned will be of the proxy.
*/
public io.vertx.reactivex.core.net.SocketAddress localAddress() {
if (cached_1 != null) {
return cached_1;
}
io.vertx.reactivex.core.net.SocketAddress ret = io.vertx.reactivex.core.net.SocketAddress.newInstance((io.vertx.core.net.SocketAddress)delegate.localAddress());
cached_1 = ret;
return ret;
}
Returns: true if this HttpConnection
is encrypted via SSL/TLS.
/**
* @return true if this {@link io.vertx.reactivex.core.http.HttpConnection} is encrypted via SSL/TLS.
*/
public boolean isSsl() {
boolean ret = delegate.isSsl();
return ret;
}
Returns the SNI server name presented during the SSL handshake by the client.
Returns: the indicated server name
/**
* Returns the SNI server name presented during the SSL handshake by the client.
* @return the indicated server name
*/
public String indicatedServerName() {
String ret = delegate.indicatedServerName();
return ret;
}
Returns: SSLSession associated with the underlying socket. Returns null if connection is not SSL.
/**
* @return SSLSession associated with the underlying socket. Returns null if connection is not SSL.
*/
public javax.net.ssl.SSLSession sslSession() {
javax.net.ssl.SSLSession ret = delegate.sslSession();
return ret;
}
private io.vertx.reactivex.core.net.SocketAddress cached_0;
private io.vertx.reactivex.core.net.SocketAddress cached_1;
public static HttpConnection newInstance(io.vertx.core.http.HttpConnection arg) {
return arg != null ? new HttpConnection(arg) : null;
}
}