Skip to content

Commit 6f208bc

Browse files
committed
Move HTTP/1.x implementation to io.vertx.core.http.impl.http1x
1 parent 9aed1b6 commit 6f208bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+147
-131
lines changed

vertx-core/src/main/java/io/vertx/core/http/impl/Http1xOrH2ChannelConnector.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import io.vertx.core.http.HttpClientOptions;
2525
import io.vertx.core.http.HttpHeaders;
2626
import io.vertx.core.http.HttpVersion;
27+
import io.vertx.core.http.impl.http1x.Http1xClientConnection;
28+
import io.vertx.core.http.impl.http1x.Http2UpgradeClientConnection;
2729
import io.vertx.core.http.impl.http2.Http2ClientChannelInitializer;
2830
import io.vertx.core.http.impl.http2.codec.Http2CodecClientChannelInitializer;
2931
import io.vertx.core.http.impl.http2.multiplex.Http2MultiplexClientChannelInitializer;

vertx-core/src/main/java/io/vertx/core/http/impl/HttpServerConnectionHandler.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import io.vertx.core.http.HttpServerRequest;
2424
import io.vertx.core.http.ServerWebSocket;
2525
import io.vertx.core.http.ServerWebSocketHandshake;
26+
import io.vertx.core.http.impl.http1x.Http1xServerConnection;
27+
import io.vertx.core.http.impl.http1x.Http1xServerRequestHandler;
2628
import io.vertx.core.http.impl.http2.Http2ServerConnection;
2729
import io.vertx.core.internal.ContextInternal;
2830

@@ -33,19 +35,19 @@
3335
*
3436
* @author <a href="mailto:[email protected]">Julien Viet</a>
3537
*/
36-
class HttpServerConnectionHandler implements Handler<HttpServerConnection> {
38+
public class HttpServerConnectionHandler implements Handler<HttpServerConnection> {
3739

38-
final HttpServerImpl server;
39-
final String serverOrigin;
40-
final Handler<HttpServerRequest> requestHandler;
41-
final Handler<HttpServerRequest> invalidRequestHandler;
42-
final Handler<ServerWebSocket> webSocketHandler;
43-
final Handler<ServerWebSocketHandshake> webSocketHandshakeHandler;
44-
final Handler<HttpConnection> connectionHandler;
45-
final Handler<Throwable> exceptionHandler;
46-
final int connectionWindowSize;
40+
public final HttpServerImpl server;
41+
public final String serverOrigin;
42+
public final Handler<HttpServerRequest> requestHandler;
43+
public final Handler<HttpServerRequest> invalidRequestHandler;
44+
public final Handler<ServerWebSocket> webSocketHandler;
45+
public final Handler<ServerWebSocketHandshake> webSocketHandshakeHandler;
46+
public final Handler<HttpConnection> connectionHandler;
47+
public final Handler<Throwable> exceptionHandler;
48+
public final int connectionWindowSize;
4749

48-
HttpServerConnectionHandler(
50+
public HttpServerConnectionHandler(
4951
HttpServerImpl server,
5052
String serverOrigin,
5153
Handler<HttpServerRequest> requestHandler,

vertx-core/src/main/java/io/vertx/core/http/impl/HttpServerConnectionInitializer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
import io.vertx.core.Handler;
2222
import io.vertx.core.ThreadingModel;
2323
import io.vertx.core.http.HttpServerOptions;
24+
import io.vertx.core.http.impl.http1x.Http1xServerConnection;
25+
import io.vertx.core.http.impl.http1x.HttpChunkContentCompressor;
26+
import io.vertx.core.http.impl.http1x.VertxHttpRequestDecoder;
27+
import io.vertx.core.http.impl.http1x.VertxHttpResponseEncoder;
2428
import io.vertx.core.http.impl.http2.Http2ServerChannelInitializer;
2529
import io.vertx.core.http.impl.http2.codec.Http2CodecServerChannelInitializer;
2630
import io.vertx.core.http.impl.http2.multiplex.Http2MultiplexServerChannelInitializer;

vertx-core/src/main/java/io/vertx/core/http/impl/HttpServerImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,4 @@ boolean requestAccept() {
278278
// Might be useful later
279279
return true;
280280
}
281-
282-
boolean wsAccept() {
283-
// Might be useful later
284-
return true;
285-
}
286281
}

vertx-core/src/main/java/io/vertx/core/http/impl/HttpUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ static void sendError(Channel ch, HttpResponseStatus status, CharSequence err) {
494494
ch.writeAndFlush(resp);
495495
}
496496

497-
static String getWebSocketLocation(HttpServerRequest req, boolean ssl) throws Exception {
497+
public static String getWebSocketLocation(HttpServerRequest req, boolean ssl) throws Exception {
498498
String prefix;
499499
if (ssl) {
500500
prefix = "wss://";
@@ -533,7 +533,7 @@ public static CharSequence toLowerCase(CharSequence sequence) {
533533
}
534534
}
535535

536-
static HttpVersion toNettyHttpVersion(io.vertx.core.http.HttpVersion version) {
536+
public static HttpVersion toNettyHttpVersion(io.vertx.core.http.HttpVersion version) {
537537
switch (version) {
538538
case HTTP_1_0: {
539539
return HttpVersion.HTTP_1_0;
@@ -911,7 +911,7 @@ public static Future<AsyncFile> resolveFile(ContextInternal context, String file
911911
}
912912
}
913913

914-
static boolean isConnectOrUpgrade(io.vertx.core.http.HttpMethod method, MultiMap headers) {
914+
public static boolean isConnectOrUpgrade(io.vertx.core.http.HttpMethod method, MultiMap headers) {
915915
if (method == io.vertx.core.http.HttpMethod.CONNECT) {
916916
return true;
917917
}
@@ -927,7 +927,7 @@ static boolean isConnectOrUpgrade(io.vertx.core.http.HttpMethod method, MultiMap
927927
return false;
928928
}
929929

930-
static boolean isKeepAlive(HttpRequest request) {
930+
public static boolean isKeepAlive(HttpRequest request) {
931931
HttpVersion version = request.protocolVersion();
932932
return (version == HttpVersion.HTTP_1_1 && !request.headers().contains(io.vertx.core.http.HttpHeaders.CONNECTION, io.vertx.core.http.HttpHeaders.CLOSE, true))
933933
|| (version == HttpVersion.HTTP_1_0 && request.headers().contains(io.vertx.core.http.HttpHeaders.CONNECTION, io.vertx.core.http.HttpHeaders.KEEP_ALIVE, true));

vertx-core/src/main/java/io/vertx/core/http/impl/ServerWebSocketHandshaker.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
import io.vertx.core.*;
2323
import io.vertx.core.buffer.Buffer;
2424
import io.vertx.core.http.*;
25+
import io.vertx.core.http.impl.http1x.Http1xServerConnection;
26+
import io.vertx.core.http.impl.http1x.Http1xServerRequest;
27+
import io.vertx.core.http.impl.http1x.Http1xServerResponse;
28+
import io.vertx.core.http.impl.http1x.HttpChunkContentCompressor;
2529
import io.vertx.core.impl.future.FutureImpl;
26-
import io.vertx.core.internal.ContextInternal;
2730
import io.vertx.core.net.HostAndPort;
2831
import io.vertx.core.net.SocketAddress;
2932
import io.vertx.core.net.impl.VertxHandler;
@@ -53,7 +56,7 @@ public class ServerWebSocketHandshaker extends FutureImpl<ServerWebSocket> imple
5356
private boolean done;
5457

5558
public ServerWebSocketHandshaker(Http1xServerRequest request, WebSocketServerHandshaker handshaker, HttpServerOptions options) {
56-
super(request.context);
59+
super(request.context());
5760
this.request = request;
5861
this.handshaker = handshaker;
5962
this.options = options;
@@ -99,7 +102,7 @@ public Future<ServerWebSocket> accept() {
99102
return rejectHandshake(BAD_REQUEST.code())
100103
.transform(ar -> {
101104
if (ar.succeeded()) {
102-
return request.context.failedFuture(e);
105+
return request.context().failedFuture(e);
103106
} else {
104107
// result is null
105108
return (Future) ar;
@@ -164,7 +167,7 @@ private ServerWebSocket acceptHandshake() {
164167
ChannelHandlerContext chctx = httpConn.channelHandlerContext();
165168
Channel channel = chctx.channel();
166169
Http1xServerResponse response = request.response();
167-
Object requestMetric = request.metric;
170+
Object requestMetric = request.metric();
168171
handshaker.handshake(channel, request.nettyRequest(), (HttpHeaders) response.headers(), channel.newPromise());
169172
response.completeHandshake();
170173
// remove compressor as it's not needed anymore once connection was upgraded to websockets
@@ -175,7 +178,7 @@ private ServerWebSocket acceptHandshake() {
175178
}
176179
VertxHandler<WebSocketConnectionImpl> handler = VertxHandler.create(ctx -> {
177180
long closingTimeoutMS = options.getWebSocketClosingTimeout() >= 0 ? options.getWebSocketClosingTimeout() * 1000L : 0L;
178-
WebSocketConnectionImpl webSocketConn = new WebSocketConnectionImpl(request.context, ctx, true, closingTimeoutMS,httpConn.metrics);
181+
WebSocketConnectionImpl webSocketConn = new WebSocketConnectionImpl(request.context(), ctx, true, closingTimeoutMS,httpConn.metrics());
179182
ServerWebSocketImpl webSocket = new ServerWebSocketImpl(
180183
request.context(),
181184
webSocketConn,
@@ -203,8 +206,8 @@ private ServerWebSocket acceptHandshake() {
203206
throw new RuntimeException(e);
204207
}
205208
ServerWebSocketImpl webSocket = (ServerWebSocketImpl) handler.getConnection().webSocket();
206-
if (METRICS_ENABLED && httpConn.metrics != null) {
207-
webSocket.setMetric(httpConn.metrics.connected(httpConn.metric(), requestMetric, this));
209+
if (METRICS_ENABLED && httpConn.metrics() != null) {
210+
webSocket.setMetric(httpConn.metrics().connected(httpConn.metric(), requestMetric, this));
208211
}
209212
webSocket.registerHandler(httpConn.context().owner().eventBus());
210213
return webSocket;

vertx-core/src/main/java/io/vertx/core/http/impl/ServerWebSocketImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
package io.vertx.core.http.impl;
1313

1414
import io.vertx.core.http.ServerWebSocket;
15+
import io.vertx.core.http.impl.http1x.Http1xServerRequest;
1516
import io.vertx.core.internal.ContextInternal;
1617
import io.vertx.core.net.HostAndPort;
17-
import io.vertx.core.net.impl.VertxConnection;
1818

1919
/**
2020
* @author <a href="http://tfox.org">Tim Fox</a>

vertx-core/src/main/java/io/vertx/core/http/impl/SharedHttpClientConnectionGroup.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import io.vertx.core.*;
1414
import io.vertx.core.http.HttpConnection;
15+
import io.vertx.core.http.impl.http1x.Http1xClientConnection;
1516
import io.vertx.core.internal.ContextInternal;
1617
import io.vertx.core.impl.NoStackTraceTimeoutException;
1718
import io.vertx.core.internal.PromiseInternal;

vertx-core/src/main/java/io/vertx/core/http/impl/WebSocketConnectionImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @author <a href="mailto:[email protected]">Julien Viet</a>
3939
*/
40-
final class WebSocketConnectionImpl extends VertxConnection {
40+
public final class WebSocketConnectionImpl extends VertxConnection {
4141

4242
private final long closingTimeoutMS;
4343
private ScheduledFuture<?> closingTimeout;
@@ -49,18 +49,18 @@ final class WebSocketConnectionImpl extends VertxConnection {
4949
private Object closeReason;
5050
private boolean closeReceived;
5151

52-
WebSocketConnectionImpl(ContextInternal context, ChannelHandlerContext chctx, boolean server, long closingTimeoutMS, TCPMetrics metrics) {
52+
public WebSocketConnectionImpl(ContextInternal context, ChannelHandlerContext chctx, boolean server, long closingTimeoutMS, TCPMetrics metrics) {
5353
super(context, chctx);
5454
this.closingTimeoutMS = closingTimeoutMS;
5555
this.metrics = metrics;
5656
this.server = server;
5757
}
5858

59-
WebSocketImplBase<?> webSocket() {
59+
public WebSocketImplBase<?> webSocket() {
6060
return webSocket;
6161
}
6262

63-
WebSocketConnectionImpl webSocket(WebSocketImplBase<?> webSocket) {
63+
public WebSocketConnectionImpl webSocket(WebSocketImplBase<?> webSocket) {
6464
this.webSocket = webSocket;
6565
return this;
6666
}
@@ -191,7 +191,7 @@ protected void handleMessage(Object msg) {
191191
}
192192
}
193193

194-
void handleWsFrame(WebSocketFrame msg) {
194+
public void handleWsFrame(WebSocketFrame msg) {
195195
WebSocketFrameInternal frame = decodeFrame(msg);
196196
WebSocketImplBase<?> w;
197197
synchronized (this) {

vertx-core/src/main/java/io/vertx/core/http/impl/WebSocketGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
import io.vertx.core.http.WebSocket;
1515
import io.vertx.core.http.WebSocketClientOptions;
1616
import io.vertx.core.http.WebSocketConnectOptions;
17+
import io.vertx.core.http.impl.http1x.Http1xClientConnection;
1718
import io.vertx.core.internal.ContextInternal;
1819
import io.vertx.core.internal.PromiseInternal;
19-
import io.vertx.core.internal.VertxInternal;
2020
import io.vertx.core.internal.resource.ManagedResource;
2121
import io.vertx.core.net.HostAndPort;
2222
import io.vertx.core.net.SocketAddress;

0 commit comments

Comments
 (0)