Skip to content

Commit 1dcc793

Browse files
authored
Merge pull request #5757 from eclipse-vertx/http-headers-rework
Revert framed HTTP stream SPI
2 parents a3214cb + 7f253bc commit 1dcc793

Some content is hidden

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

47 files changed

+787
-669
lines changed

vertx-core/src/main/java/io/vertx/core/MultiMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
package io.vertx.core;
1313

1414
import io.vertx.codegen.annotations.*;
15-
import io.vertx.core.http.impl.headers.HeadersMultiMap;
15+
import io.vertx.core.http.impl.headers.Http1xHeaders;
1616

1717
import java.util.ArrayList;
1818
import java.util.List;
@@ -40,7 +40,7 @@ public interface MultiMap extends Iterable<Map.Entry<String, String>> {
4040
* @return the multi-map
4141
*/
4242
static MultiMap caseInsensitiveMultiMap() {
43-
return HeadersMultiMap.caseInsensitive();
43+
return Http1xHeaders.caseInsensitive();
4444
}
4545

4646
@GenIgnore(GenIgnore.PERMITTED_TYPE)

vertx-core/src/main/java/io/vertx/core/http/HttpHeaders.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
import io.vertx.codegen.annotations.GenIgnore;
2020
import io.vertx.codegen.annotations.VertxGen;
2121
import io.vertx.core.MultiMap;
22-
import io.vertx.core.http.impl.headers.HeadersMultiMap;
23-
import io.vertx.core.http.impl.spi.Http2HeadersMultiMap;
22+
import io.vertx.core.http.impl.headers.Http1xHeaders;
2423

2524
/**
2625
* Contains a bunch of useful HTTP headers stuff:
@@ -494,7 +493,7 @@ static CharSequence createOptimized(String value) {
494493
* @return a {@link MultiMap} backing an HTTP headers structure optimized for {@code HTTP/1.x}
495494
*/
496495
static MultiMap headers() {
497-
return HeadersMultiMap.httpHeaders();
496+
return Http1xHeaders.httpHeaders();
498497
}
499498

500499
/**
@@ -505,20 +504,20 @@ static MultiMap headers(HttpVersion version) {
505504
switch (version) {
506505
case HTTP_1_0:
507506
case HTTP_1_1:
508-
return HeadersMultiMap.httpHeaders();
507+
return Http1xHeaders.httpHeaders();
509508
case HTTP_2:
510-
return new Http2HeadersMultiMap(new DefaultHttp2Headers());
509+
return new io.vertx.core.http.impl.headers.HttpHeaders(new DefaultHttp2Headers());
511510
default:
512511
throw new AssertionError();
513512
}
514513
}
515514

516515
static MultiMap set(String name, String value) {
517-
return HeadersMultiMap.httpHeaders().set(name, value);
516+
return Http1xHeaders.httpHeaders().set(name, value);
518517
}
519518

520519
@GenIgnore(GenIgnore.PERMITTED_TYPE)
521520
static MultiMap set(CharSequence name, CharSequence value) {
522-
return HeadersMultiMap.httpHeaders().set(name, value);
521+
return Http1xHeaders.httpHeaders().set(name, value);
523522
}
524523
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import io.vertx.core.http.HttpVersion;
3838
import io.vertx.core.http.WebSocketVersion;
3939
import io.vertx.core.http.impl.headers.HeadersAdaptor;
40+
import io.vertx.core.http.impl.headers.Http1xHeaders;
4041
import io.vertx.core.internal.ContextInternal;
4142
import io.vertx.core.internal.PromiseInternal;
4243
import io.vertx.core.internal.buffer.BufferInternal;
@@ -115,6 +116,11 @@ public class Http1xClientConnection extends Http1xConnection implements HttpClie
115116
this.expirationTimestamp = expirationTimestampOf(keepAliveTimeout);
116117
}
117118

119+
@Override
120+
public MultiMap newHttpRequestHeaders() {
121+
return Http1xHeaders.httpHeaders();
122+
}
123+
118124
@Override
119125
public HostAndPort authority() {
120126
return authority;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.netty.channel.ChannelPromise;
1919
import io.netty.channel.EventLoop;
2020
import io.netty.handler.codec.DecoderResult;
21+
import io.netty.handler.codec.Headers;
2122
import io.netty.handler.codec.http.*;
2223
import io.netty.handler.codec.http.websocketx.WebSocketDecoderConfig;
2324
import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException;
@@ -28,7 +29,6 @@
2829
import io.vertx.core.*;
2930
import io.vertx.core.buffer.Buffer;
3031
import io.vertx.core.http.ServerWebSocketHandshake;
31-
import io.vertx.core.http.impl.headers.HeadersMultiMap;
3232
import io.vertx.core.internal.buffer.BufferInternal;
3333
import io.vertx.core.http.HttpServerOptions;
3434
import io.vertx.core.http.HttpServerRequest;
@@ -116,8 +116,8 @@ protected void handleShutdown(ChannelPromise promise) {
116116
}
117117

118118
@Override
119-
public MultiMap newHeaders() {
120-
return io.vertx.core.http.HttpHeaders.headers();
119+
public Headers<CharSequence, CharSequence, ?> newHeaders() {
120+
throw new UnsupportedOperationException();
121121
}
122122

123123
@Override

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import io.vertx.core.http.HttpHeaders;
3030
import io.vertx.core.http.HttpMethod;
3131
import io.vertx.core.internal.buffer.BufferInternal;
32-
import io.vertx.core.http.impl.headers.HeadersMultiMap;
32+
import io.vertx.core.http.impl.headers.Http1xHeaders;
3333
import io.vertx.core.internal.ContextInternal;
3434
import io.vertx.core.internal.VertxInternal;
3535
import io.vertx.core.internal.PromiseInternal;
@@ -43,8 +43,6 @@
4343
import java.io.RandomAccessFile;
4444
import java.nio.channels.FileChannel;
4545
import java.util.Set;
46-
import java.util.function.Function;
47-
import java.util.function.Supplier;
4846

4947
import static io.vertx.core.http.HttpHeaders.*;
5048

@@ -75,7 +73,7 @@ public class Http1xServerResponse implements HttpServerResponse, HttpResponse {
7573
private Handler<Void> headersEndHandler;
7674
private Handler<Void> bodyEndHandler;
7775
private boolean closed;
78-
private final HeadersMultiMap headers;
76+
private final Http1xHeaders headers;
7977
private CookieJar cookies;
8078
private MultiMap trailers;
8179
private io.netty.handler.codec.http.HttpHeaders trailingHeaders = EmptyHttpHeaders.INSTANCE;
@@ -93,7 +91,7 @@ public class Http1xServerResponse implements HttpServerResponse, HttpResponse {
9391
this.conn = conn;
9492
this.context = context;
9593
this.version = request.protocolVersion();
96-
this.headers = HeadersMultiMap.httpHeaders();
94+
this.headers = Http1xHeaders.httpHeaders();
9795
this.request = request;
9896
this.status = HttpResponseStatus.OK;
9997
this.requestMetric = requestMetric;
@@ -115,7 +113,7 @@ public MultiMap headers() {
115113
@Override
116114
public MultiMap trailers() {
117115
if (trailers == null) {
118-
HeadersMultiMap v = HeadersMultiMap.httpHeaders();
116+
Http1xHeaders v = Http1xHeaders.httpHeaders();
119117
trailers = v;
120118
trailingHeaders = v;
121119
}
@@ -361,11 +359,11 @@ public Future<Void> writeContinue() {
361359
public Future<Void> writeEarlyHints(MultiMap headers) {
362360
checkThread();
363361
PromiseInternal<Void> promise = context.promise();
364-
HeadersMultiMap headersMultiMap;
365-
if (headers instanceof HeadersMultiMap) {
366-
headersMultiMap = (HeadersMultiMap) headers;
362+
Http1xHeaders headersMultiMap;
363+
if (headers instanceof Http1xHeaders) {
364+
headersMultiMap = (Http1xHeaders) headers;
367365
} else {
368-
headersMultiMap = HeadersMultiMap.httpHeaders();
366+
headersMultiMap = Http1xHeaders.httpHeaders();
369367
headersMultiMap.addAll(headers);
370368
}
371369
synchronized (conn) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.vertx.core.buffer.Buffer;
2323
import io.vertx.core.http.*;
2424
import io.vertx.core.http.HttpVersion;
25+
import io.vertx.core.http.impl.headers.Http1xHeaders;
2526
import io.vertx.core.internal.ContextInternal;
2627
import io.vertx.core.internal.PromiseInternal;
2728
import io.vertx.core.internal.logging.Logger;
@@ -69,6 +70,11 @@ public HttpClientConnection unwrap() {
6970
return current;
7071
}
7172

73+
@Override
74+
public MultiMap newHttpRequestHeaders() {
75+
return Http1xHeaders.httpHeaders();
76+
}
77+
7278
@Override
7379
public HostAndPort authority() {
7480
return current.authority();

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
package io.vertx.core.http.impl;
1313

1414
import io.netty.channel.ChannelHandlerContext;
15+
import io.netty.handler.codec.Headers;
1516
import io.vertx.core.Future;
1617
import io.vertx.core.Handler;
18+
import io.vertx.core.MultiMap;
1719
import io.vertx.core.http.HttpConnection;
1820
import io.vertx.core.internal.ContextInternal;
1921
import io.vertx.core.internal.logging.Logger;
@@ -33,6 +35,8 @@ public interface HttpClientConnection extends HttpConnection {
3335

3436
Handler<Long> DEFAULT_CONCURRENCY_CHANGE_HANDLER = concurrency -> {};
3537

38+
MultiMap newHttpRequestHeaders();
39+
3640
/**
3741
* @return the number of active request/response (streams)
3842
*/

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import io.vertx.core.internal.ContextInternal;
2020
import io.vertx.core.internal.buffer.BufferInternal;
2121
import io.vertx.core.http.*;
22-
import io.vertx.core.http.impl.headers.HeadersMultiMap;
22+
import io.vertx.core.http.impl.headers.Http1xHeaders;
2323
import io.vertx.core.impl.Arguments;
2424
import io.vertx.core.internal.logging.Logger;
2525
import io.vertx.core.internal.logging.LoggerFactory;
@@ -54,7 +54,7 @@ public class HttpClientRequestImpl extends HttpClientRequestBase implements Http
5454
private boolean followRedirects;
5555
private int maxRedirects;
5656
private int numberOfRedirections;
57-
private HeadersMultiMap headers;
57+
private MultiMap headers;
5858
private StreamPriority priority;
5959
private boolean headWritten;
6060
private boolean isConnect;
@@ -184,7 +184,7 @@ public synchronized boolean isChunked() {
184184
@Override
185185
public synchronized MultiMap headers() {
186186
if (headers == null) {
187-
headers = HeadersMultiMap.httpHeaders();
187+
headers = Http1xHeaders.httpHeaders();
188188
}
189189
return headers;
190190
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
package io.vertx.core.http.impl;
1212

1313
import io.netty.channel.ChannelHandlerContext;
14+
import io.netty.handler.codec.Headers;
1415
import io.vertx.core.Handler;
15-
import io.vertx.core.MultiMap;
1616
import io.vertx.core.http.HttpConnection;
1717
import io.vertx.core.internal.ContextInternal;
1818

@@ -23,7 +23,7 @@ public interface HttpServerConnection extends HttpConnection {
2323

2424
HttpServerConnection streamHandler(Handler<HttpServerStream> handler);
2525

26-
MultiMap newHeaders();
26+
Headers<CharSequence, CharSequence, ?> newHeaders();
2727

2828
boolean supportsSendFile();
2929

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
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.spi.HttpServerConnectionProvider;
26+
import io.vertx.core.http.impl.http2.Http2ServerConnection;
2727
import io.vertx.core.internal.ContextInternal;
2828

2929
import java.util.ArrayList;
@@ -96,12 +96,12 @@ public void handle(HttpServerConnection conn) {
9696
http1Conn.handler(requestHandler);
9797
http1Conn.invalidRequestHandler(invalidRequestHandler);
9898
} else {
99-
HttpServerConnectionProvider http2Conn = (HttpServerConnectionProvider) conn;
99+
Http2ServerConnection http2Conn = (Http2ServerConnection) conn;
100100
http2Conn.streamHandler(stream -> {
101101
HttpServerOptions options = server.options;
102-
HttpServerRequestImpl request = new HttpServerRequestImpl(stream, stream.context(), options.isHandle100ContinueAutomatically(),
103-
options.getMaxFormAttributeSize(), options.getMaxFormFields(), options.getMaxFormBufferedBytes(), serverOrigin);
104-
request.handler = requestHandler;
102+
HttpServerRequestImpl request = new HttpServerRequestImpl(requestHandler, stream, stream.context(),
103+
options.isHandle100ContinueAutomatically(), options.getMaxFormAttributeSize(), options.getMaxFormFields(),
104+
options.getMaxFormBufferedBytes(), serverOrigin);
105105
request.init();
106106
});
107107
}

0 commit comments

Comments
 (0)