Skip to content

Commit d718a3d

Browse files
committed
HttpClientRequestImpl now allocates its headers to sent upfront using HttpClientConnection#newHttpRequestHeaders
1 parent c5a10d2 commit d718a3d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ public class HttpClientRequestImpl extends HttpClientRequestBase implements Http
6060
private boolean isConnect;
6161
private String traceOperation;
6262

63-
HttpClientRequestImpl(HttpConnection connection, HttpClientStream stream) {
63+
public HttpClientRequestImpl(HttpConnection connection, HttpClientStream stream) {
6464
super(connection, stream, stream.context().promise(), HttpMethod.GET, "/");
6565
this.chunked = false;
6666
this.endPromise = context.promise();
6767
this.endFuture = endPromise.future();
6868
this.priority = HttpUtils.DEFAULT_STREAM_PRIORITY;
6969
this.numberOfRedirections = 0;
70+
this.headers = stream.connection().newHttpRequestHeaders();
7071

7172
//
7273
stream.continueHandler(this::handleContinue);
@@ -182,10 +183,7 @@ public synchronized boolean isChunked() {
182183
}
183184

184185
@Override
185-
public synchronized MultiMap headers() {
186-
if (headers == null) {
187-
headers = Http1xHeaders.httpHeaders();
188-
}
186+
public MultiMap headers() {
189187
return headers;
190188
}
191189

@@ -492,7 +490,7 @@ public Future<Void> write(String chunk, String enc) {
492490
}
493491

494492
private boolean requiresContentLength() {
495-
return !chunked && (headers == null || !headers.contains(CONTENT_LENGTH)) && !isConnect;
493+
return !chunked && !headers.contains(CONTENT_LENGTH) && !isConnect;
496494
}
497495

498496
private Future<Void> write(Buffer buff, boolean end) {

0 commit comments

Comments
 (0)