/*
 * 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 java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import javax.net.ssl.SSLSession;
import io.vertx.core.http.GoAway;
import io.vertx.core.http.Http2Settings;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;

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. */
@io.vertx.lang.rx.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 io.vertx.lang.rx.TypeArg<HttpConnection> __TYPE_ARG = new io.vertx.lang.rx.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 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<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 connection shutdown, a go away frame is sent and the connection is closed when all current active streams are closed or after a time out of 30 seconds.

This is not implemented for HTTP/1.x.
Returns:a reference to this, so the API can be used fluently
/** * Initiate a connection shutdown, a go away frame is sent and the connection is closed when all current active streams * are closed or after a time out of 30 seconds. * <p/> * This is not implemented for HTTP/1.x. * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.core.http.HttpConnection shutdown() { delegate.shutdown(); return this; }
Initiate a connection shutdown, a go away frame is sent and the connection is closed when all current streams will be closed or the timeout is fired.

This is not implemented for HTTP/1.x.
Params:
  • timeoutMs – the timeout in milliseconds
Returns:a reference to this, so the API can be used fluently
/** * Initiate a connection shutdown, a go away frame is sent and the connection is closed when all current streams * will be closed or the <code>timeout</code> is fired. * <p/> * This is not implemented for HTTP/1.x. * @param timeoutMs the timeout in milliseconds * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.core.http.HttpConnection shutdown(long timeoutMs) { delegate.shutdown(timeoutMs); return this; }
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.
/** * Close the connection and all the currently active streams. * <p/> * An HTTP/2 connection will send a frame before. */
public void close() { delegate.close(); }
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 Http2Settings settings() { Http2Settings ret = delegate.settings(); return ret; }
Send to the remote endpoint an update of the server 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 the server 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(Http2Settings settings) { delegate.updateSettings(settings); 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
  • 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(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 Completable rxUpdateSettings(Http2Settings settings) { return io.vertx.reactivex.impl.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 Http2Settings remoteSettings() { 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<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(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 Single<io.vertx.reactivex.core.buffer.Buffer> rxPing(io.vertx.reactivex.core.buffer.Buffer data) { return io.vertx.reactivex.impl.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(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<Throwable> handler) { delegate.exceptionHandler(handler); return this; }
Returns:the remote address for this connection
/** * @return the remote address for this connection */
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(delegate.remoteAddress()); cached_0 = ret; return ret; }
Returns:the remote address for this connection
/** * @return the remote address for this connection */
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(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 SSLSession sslSession() { 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; } }