diff --git a/src/main/java/io/vertx/core/http/HttpClientRequest.java b/src/main/java/io/vertx/core/http/HttpClientRequest.java index 7ac17c89884..2e7fc146694 100644 --- a/src/main/java/io/vertx/core/http/HttpClientRequest.java +++ b/src/main/java/io/vertx/core/http/HttpClientRequest.java @@ -282,4 +282,9 @@ public interface HttpClientRequest extends WriteStream, ReadStream completionHandler) { + throw new UnsupportedOperationException(); + } + + @Override + public HttpConnection shutdown() { + throw new UnsupportedOperationException(); + } + + @Override + public HttpConnection shutdown(long timeout) { + throw new UnsupportedOperationException(); + } + + @Override + public HttpConnection closeHandler(Handler handler) { + throw new UnsupportedOperationException(); + } + + @Override + public io.vertx.core.http.Http2Settings settings() { + throw new UnsupportedOperationException(); + } + + @Override + public HttpConnection updateSettings(io.vertx.core.http.Http2Settings settings) { + throw new UnsupportedOperationException(); + } + + @Override + public HttpConnection updateSettings(io.vertx.core.http.Http2Settings settings, Handler> completionHandler) { + throw new UnsupportedOperationException(); + } + + @Override + public io.vertx.core.http.Http2Settings remoteSettings() { + throw new UnsupportedOperationException(); + } + + @Override + public HttpConnection remoteSettingsHandler(Handler handler) { + throw new UnsupportedOperationException(); + } + + @Override + public Handler remoteSettingsHandler() { + throw new UnsupportedOperationException(); + } + + @Override + public HttpConnection exceptionHandler(Handler handler) { + throw new UnsupportedOperationException(); + } + + @Override + public Handler exceptionHandler() { + throw new UnsupportedOperationException(); + } + void handle(Handler handler, HttpClientRequestImpl req) { Http2ClientStream stream = createStream(req); handler.handle(stream); @@ -315,7 +380,7 @@ Http2ClientStream createStream(HttpClientRequestBase req) { try { Http2Connection conn = connection(); Http2Stream stream = conn.local().createStream(conn.local().incrementAndGetNextStreamId(), false); - Http2ClientStream clientStream = new Http2ClientStream(req, stream, context, handlerCtx, conn, encoder()); + Http2ClientStream clientStream = new Http2ClientStream(this, req, stream); streams.put(clientStream.stream.id(), clientStream); return clientStream; } catch (Http2Exception e) { @@ -374,7 +439,7 @@ public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promi String host = headers.authority() != null ? headers.authority().toString() : null; MultiMap headersMap = new Http2HeadersAdaptor(headers); Http2Stream promisedStream = connection().stream(promisedStreamId); - HttpClientRequestPushPromise promisedReq = new HttpClientRequestPushPromise(promisedStream, context, handlerCtx, connection(), encoder(), client, method, uri, host, headersMap); + HttpClientRequestPushPromise promisedReq = new HttpClientRequestPushPromise(this, promisedStream, client, method, uri, host, headersMap); streams.put(promisedStreamId, promisedReq.getStream()); stream.handlePushPromise(promisedReq); } diff --git a/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java b/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java index 2459fb04f88..5c05b9b9128 100644 --- a/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java +++ b/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java @@ -25,6 +25,7 @@ import io.vertx.core.http.CaseInsensitiveHeaders; import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpClientResponse; +import io.vertx.core.http.HttpConnection; import io.vertx.core.http.HttpVersion; import io.vertx.core.impl.VertxInternal; import io.vertx.core.net.NetSocket; @@ -352,6 +353,16 @@ public void reset(long code) { } } + @Override + public HttpConnection connection() { + synchronized (getLock()) { + if (conn == null) { + throw new IllegalStateException("Not yet connected"); + } + return conn.connection(); + } + } + void handleDrained() { synchronized (getLock()) { if (!completed && drainHandler != null) { diff --git a/src/main/java/io/vertx/core/http/impl/HttpClientRequestPushPromise.java b/src/main/java/io/vertx/core/http/impl/HttpClientRequestPushPromise.java index 3d8c18d3a7f..e762b7d9009 100644 --- a/src/main/java/io/vertx/core/http/impl/HttpClientRequestPushPromise.java +++ b/src/main/java/io/vertx/core/http/impl/HttpClientRequestPushPromise.java @@ -27,6 +27,7 @@ import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpClientRequest; import io.vertx.core.http.HttpClientResponse; +import io.vertx.core.http.HttpConnection; import io.vertx.core.http.HttpMethod; import io.vertx.core.impl.ContextImpl; @@ -35,6 +36,7 @@ */ class HttpClientRequestPushPromise extends HttpClientRequestBase { + private final Http2Pool.VertxClientHandler handler; private final Http2Pool.Http2ClientStream clientStream; private final HttpMethod method; private final String uri; @@ -43,18 +45,16 @@ class HttpClientRequestPushPromise extends HttpClientRequestBase { private Handler respHandler; public HttpClientRequestPushPromise( + Http2Pool.VertxClientHandler handler, Http2Stream clientStream, - ContextImpl context, - ChannelHandlerContext handlerCtx, - Http2Connection conn, - Http2ConnectionEncoder encoder, HttpClientImpl client, HttpMethod method, String uri, String host, MultiMap headers) throws Http2Exception { super(client); - this.clientStream = new Http2Pool.Http2ClientStream(this, clientStream, context, handlerCtx, conn, encoder); + this.handler = handler; + this.clientStream = new Http2Pool.Http2ClientStream(handler, this, clientStream); this.method = method; this.uri = uri; this.host = host; @@ -91,6 +91,11 @@ public HttpClientRequest handler(Handler handler) { } } + @Override + public HttpConnection connection() { + return handler; + } + @Override public void reset(long code) { clientStream.reset(code); diff --git a/src/main/java/io/vertx/core/http/impl/HttpClientStream.java b/src/main/java/io/vertx/core/http/impl/HttpClientStream.java index 7c9260ea0c9..d45cc629498 100644 --- a/src/main/java/io/vertx/core/http/impl/HttpClientStream.java +++ b/src/main/java/io/vertx/core/http/impl/HttpClientStream.java @@ -19,6 +19,7 @@ import io.netty.buffer.ByteBuf; import io.vertx.core.Context; import io.vertx.core.MultiMap; +import io.vertx.core.http.HttpConnection; import io.vertx.core.http.HttpMethod; import io.vertx.core.net.NetSocket; @@ -49,4 +50,5 @@ interface HttpClientStream { void reportBytesRead(long s); NetSocket createNetSocket(); + HttpConnection connection(); }