Skip to content

Commit

Permalink
Move common code in Http1xConnectionBase and make Http1xConnectionBas…
Browse files Browse the repository at this point in the history
…e implement HttpConnection interface
  • Loading branch information
vietj committed Jun 25, 2017
1 parent 2279bb5 commit e3eebd2
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 154 deletions.
74 changes: 0 additions & 74 deletions src/main/java/io/vertx/core/http/impl/ClientConnection.java
Expand Up @@ -22,8 +22,6 @@
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.websocketx.*;
import io.netty.util.ReferenceCountUtil;
import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
import io.vertx.core.VertxException;
Expand All @@ -36,7 +34,6 @@
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.net.NetSocket;
import io.vertx.core.net.impl.ConnectionBase;
import io.vertx.core.net.impl.NetSocketImpl;
import io.vertx.core.net.impl.VertxNetHandler;
import io.vertx.core.spi.metrics.HttpClientMetrics;
Expand Down Expand Up @@ -254,10 +251,6 @@ private void handshakeComplete(ChannelHandlerContext ctx, FullHttpResponse respo
}
}

public ClientConnection closeHandler(Handler<Void> handler) {
return (ClientConnection) super.closeHandler(handler);
}

public boolean isValid() {
return chctx.channel().isOpen();
}
Expand Down Expand Up @@ -644,71 +637,4 @@ public HttpVersion version() {
public int id() {
return -1;
}

//

@Override
public HttpConnection goAway(long errorCode, int lastStreamId, Buffer debugData) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection goAwayHandler(@Nullable Handler<GoAway> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection shutdownHandler(@Nullable Handler<Void> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection shutdown() {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection shutdown(long timeoutMs) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public Http2Settings settings() {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection updateSettings(Http2Settings settings) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection updateSettings(Http2Settings settings, Handler<AsyncResult<Void>> completionHandler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public Http2Settings remoteSettings() {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection remoteSettingsHandler(Handler<Http2Settings> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection ping(Buffer data, Handler<AsyncResult<Buffer>> pongHandler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support PING");
}

@Override
public HttpConnection pingHandler(@Nullable Handler<Buffer> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support PING");
}

@Override
public ClientConnection exceptionHandler(Handler<Throwable> handler) {
return (ClientConnection) super.exceptionHandler(handler);
}
}
79 changes: 78 additions & 1 deletion src/main/java/io/vertx/core/http/impl/Http1xConnectionBase.java
Expand Up @@ -24,6 +24,13 @@
import io.netty.handler.codec.http.websocketx.PingWebSocketFrame;
import io.netty.handler.codec.http.websocketx.PongWebSocketFrame;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.GoAway;
import io.vertx.core.http.Http2Settings;
import io.vertx.core.http.HttpConnection;
import io.vertx.core.http.impl.ws.WebSocketFrameInternal;
import io.vertx.core.impl.ContextImpl;
import io.vertx.core.impl.VertxInternal;
Expand All @@ -34,7 +41,7 @@
/**
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
*/
abstract class Http1xConnectionBase extends ConnectionBase {
abstract class Http1xConnectionBase extends ConnectionBase implements io.vertx.core.http.HttpConnection {

Http1xConnectionBase(VertxInternal vertx, ChannelHandlerContext chctx, ContextImpl context) {
super(vertx, chctx, context);
Expand Down Expand Up @@ -73,4 +80,74 @@ protected Object encode(Object obj) {
}
return super.encode(obj);
}

@Override
public Http1xConnectionBase closeHandler(Handler<Void> handler) {
return (Http1xConnectionBase) super.closeHandler(handler);
}

@Override
public Http1xConnectionBase exceptionHandler(Handler<Throwable> handler) {
return (Http1xConnectionBase) super.exceptionHandler(handler);
}

@Override
public HttpConnection goAway(long errorCode, int lastStreamId, Buffer debugData) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection goAwayHandler(@Nullable Handler<GoAway> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection shutdownHandler(@Nullable Handler<Void> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection shutdown() {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection shutdown(long timeoutMs) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public Http2Settings settings() {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection updateSettings(Http2Settings settings) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection updateSettings(Http2Settings settings, Handler<AsyncResult<Void>> completionHandler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public Http2Settings remoteSettings() {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection remoteSettingsHandler(Handler<Http2Settings> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection ping(Buffer data, Handler<AsyncResult<Buffer>> pongHandler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support PING");
}

@Override
public HttpConnection pingHandler(@Nullable Handler<Buffer> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support PING");
}
}
79 changes: 0 additions & 79 deletions src/main/java/io/vertx/core/http/impl/ServerConnection.java
Expand Up @@ -17,10 +17,8 @@
package io.vertx.core.http.impl;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
Expand All @@ -42,13 +40,10 @@
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.handler.stream.ChunkedFile;
import io.netty.util.ReferenceCountUtil;
import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.GoAway;
import io.vertx.core.http.Http2Settings;
import io.vertx.core.http.HttpConnection;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.http.HttpServerRequest;
Expand All @@ -60,7 +55,6 @@
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.net.NetSocket;
import io.vertx.core.net.impl.ConnectionBase;
import io.vertx.core.net.impl.NetSocketImpl;
import io.vertx.core.net.impl.SSLHelper;
import io.vertx.core.net.impl.VertxNetHandler;
Expand Down Expand Up @@ -552,77 +546,4 @@ private long getBytes(Object obj) {
return -1;
}
}

//


@Override
public synchronized ServerConnection closeHandler(Handler<Void> handler) {
return (ServerConnection) super.closeHandler(handler);
}

@Override
public synchronized ServerConnection exceptionHandler(Handler<Throwable> handler) {
return (ServerConnection) super.exceptionHandler(handler);
}

@Override
public HttpConnection goAway(long errorCode, int lastStreamId, Buffer debugData) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection goAwayHandler(@Nullable Handler<GoAway> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection shutdownHandler(@Nullable Handler<Void> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection shutdown() {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public HttpConnection shutdown(long timeoutMs) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support GOAWAY");
}

@Override
public Http2Settings settings() {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection updateSettings(Http2Settings settings) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection updateSettings(Http2Settings settings, Handler<AsyncResult<Void>> completionHandler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public Http2Settings remoteSettings() {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection remoteSettingsHandler(Handler<Http2Settings> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support SETTINGS");
}

@Override
public HttpConnection ping(Buffer data, Handler<AsyncResult<Buffer>> pongHandler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support PING");
}

@Override
public HttpConnection pingHandler(@Nullable Handler<Buffer> handler) {
throw new UnsupportedOperationException("HTTP/1.x connections don't support PING");
}
}

0 comments on commit e3eebd2

Please sign in to comment.