Skip to content

Commit 473c0ed

Browse files
committed
Avoid using deprecated sendHead method
1 parent 420d4cc commit 473c0ed

11 files changed

Lines changed: 53 additions & 53 deletions

File tree

vertx-core/src/main/asciidoc/http.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ client request object
14961496
This will be called if the server sends back a `Status: 100 (Continue)` response to signify that it is ok to send
14971497
the rest of the request.
14981498

1499-
This is used in conjunction with {@link io.vertx.core.http.HttpClientRequest#sendHead()}to send the head of the request.
1499+
This is used in conjunction with {@link io.vertx.core.http.HttpClientRequest#writeHead()} to write the head of the request.
15001500

15011501
Here's an example:
15021502

vertx-core/src/main/java/examples/HTTPExamples.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ public void example50(HttpClient client) {
10131013
request.end();
10141014
});
10151015

1016-
request.sendHead();
1016+
request.writeHead();
10171017
});
10181018
}
10191019

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public interface HttpClientRequest extends WriteStream<Buffer> {
252252
* has been set using this method, then the {@code handler} will be called.
253253
* <p>
254254
* You can then continue to write data to the request body and later end it. This is normally used in conjunction with
255-
* the {@link #sendHead()} method to force the request header to be written before the request has ended.
255+
* the {@link #writeHead()} method to force the request header to be written before the request has ended.
256256
*
257257
* @return a reference to this, so the API can be used fluently
258258
*/
@@ -411,7 +411,7 @@ default Future<HttpClientResponse> send(ReadStream<Buffer> body) {
411411
Future<Void> end(Buffer chunk);
412412

413413
/**
414-
* Ends the request. If no data has been written to the request body, and {@link #sendHead()} has not been called then
414+
* Ends the request. If no data has been written to the request body, and {@link #writeHead()} has not been called then
415415
* the actual request won't get written until this method gets called.
416416
* <p>
417417
* Once the request has ended, it cannot be used any more,
@@ -510,7 +510,7 @@ default Future<Void> reset() {
510510
* The frame is sent immediatly and is not subject to flow control.<p>
511511
*
512512
* This method must be called after the request headers have been sent and only for the protocol HTTP/2.
513-
* The {@link #sendHead()} should be used for this purpose.
513+
* The {@link #writeHead()} should be used for this purpose.
514514
*
515515
* @param type the 8-bit frame type
516516
* @param flags the 8-bit frame flags

vertx-core/src/test/java/io/vertx/tests/http/Http1xTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,7 @@ public void testRequestExceptionHandlerContext() throws Exception {
19511951
assertSameEventLoop(clientCtx, Vertx.currentContext());
19521952
complete();
19531953
}));
1954-
req.sendHead();
1954+
req.writeHead();
19551955
}));
19561956
});
19571957
await();
@@ -2077,7 +2077,7 @@ public void testContexts() throws Exception {
20772077
assertSameEventLoop(requestCtx, Vertx.currentContext());
20782078
req.end();
20792079
});
2080-
req.sendHead().onComplete(version -> {
2080+
req.writeHead().onComplete(version -> {
20812081
assertSameEventLoop(requestCtx, Vertx.currentContext());
20822082
fill(data, req, cf::complete);
20832083
});
@@ -2796,7 +2796,7 @@ public void testDoNotReuseConnectionWhenResponseEndsBeforeRequest() throws Excep
27962796
// Send head to the server and trigger the request handler
27972797
req
27982798
.setChunked(true)
2799-
.sendHead();
2799+
.writeHead();
28002800
}));
28012801

28022802
client.request(new RequestOptions(requestOptions).setURI("/2"))
@@ -2866,7 +2866,7 @@ public void testClientConnectionExceptionHandler() throws Exception {
28662866
})
28672867
.build();
28682868
client.request(requestOptions)
2869-
.onComplete(onSuccess(HttpClientRequest::sendHead));
2869+
.onComplete(onSuccess(HttpClientRequest::writeHead));
28702870
await();
28712871
}
28722872

@@ -2890,7 +2890,7 @@ public void testServerConnectionExceptionHandler() throws Exception {
28902890
client.request(requestOptions)
28912891
.onComplete(onSuccess(req -> {
28922892
req.putHeader("the_header", TestUtils.randomAlphaString(10000));
2893-
req.sendHead();
2893+
req.writeHead();
28942894
}));
28952895
});
28962896
await();
@@ -2911,7 +2911,7 @@ public void testServerExceptionHandler() throws Exception {
29112911
client.request(requestOptions).onComplete(onSuccess(req -> {
29122912
req
29132913
.putHeader("the_header", TestUtils.randomAlphaString(10000))
2914-
.sendHead();
2914+
.writeHead();
29152915
}));
29162916
await();
29172917
}
@@ -3087,7 +3087,7 @@ public void testResetKeepAliveClientRequest() throws Exception {
30873087
client.request(requestOptions).onSuccess(req2 -> {
30883088
req2
30893089
.response().onComplete(onFailure(err -> complete()));
3090-
req2.sendHead().onComplete(onSuccess(v -> {
3090+
req2.writeHead().onComplete(onSuccess(v -> {
30913091
assertTrue(req2.reset().succeeded());
30923092
}));
30933093
});
@@ -3153,7 +3153,7 @@ public void testResetPipelinedClientRequest() throws Exception {
31533153
.setMethod(HttpMethod.POST)
31543154
).onComplete(onSuccess(req2 -> {
31553155
req2.response().onComplete(onFailure(resp -> complete()));
3156-
req2.sendHead();
3156+
req2.writeHead();
31573157
doReset.thenAccept(v2 -> {
31583158
assertTrue(req2.reset().succeeded());
31593159
});
@@ -3242,11 +3242,11 @@ private void testCloseTheConnectionAfterResetPersistentClientRequest(boolean pip
32423242
complete();
32433243
}));
32443244
});
3245-
req1.sendHead().onComplete(v -> {
3245+
req1.writeHead().onComplete(v -> {
32463246
assertTrue(req1.reset().succeeded());
32473247
});
32483248
} else {
3249-
req1.sendHead().onComplete(v -> {
3249+
req1.writeHead().onComplete(v -> {
32503250
assertTrue(req1.reset().succeeded());
32513251
});
32523252
client.request(new RequestOptions(requestOptions).setURI("/somepath"))
@@ -4440,7 +4440,7 @@ public void testPipeliningQueueDelayed() throws Exception {
44404440
client.request(requestOptions)
44414441
.onComplete(onSuccess(req -> {
44424442
req.response().onComplete(onSuccess(resp -> complete()));
4443-
req.sendHead();
4443+
req.writeHead();
44444444
client.request(requestOptions).compose(HttpClientRequest::send).onComplete(resp -> complete());
44454445
client.request(requestOptions).compose(HttpClientRequest::send).onComplete(resp -> complete());
44464446
// Need to wait a little so requests 2 and 3 are appended to the first request
@@ -4570,7 +4570,7 @@ public void testHttpClientRequestShouldCallExceptionHandlerWhenTheClosedHandlerI
45704570
testComplete();
45714571
}
45724572
});
4573-
req.sendHead().onComplete(onSuccess(v -> {
4573+
req.writeHead().onComplete(onSuccess(v -> {
45744574
connected.set(true);
45754575
sender.send();
45764576
}));
@@ -4977,7 +4977,7 @@ public void testClientConnectionGracefulShutdownWhenRequestCompletedAfterRespons
49774977
});
49784978
});
49794979
}));
4980-
req.setChunked(true).sendHead();
4980+
req.setChunked(true).writeHead();
49814981
}));
49824982
await();
49834983
}
@@ -5535,7 +5535,7 @@ public void testDoNotRecycleWhenRequestIsNotEnded() throws Exception {
55355535
case 0:
55365536
assertTrue(ar.succeeded());
55375537
HttpClientRequest req = ar.result();
5538-
req.sendHead();
5538+
req.writeHead();
55395539
req.response().onComplete(onSuccess(resp -> {
55405540
complete();
55415541
}));
@@ -5563,7 +5563,7 @@ public void testRecycleConnectionOnRequestEnd() throws Exception {
55635563
for (int i = 0;i < numRequests;i++) {
55645564
Future<HttpClientRequest> fut = client.request(requestOptions);
55655565
fut.onComplete(onSuccess(request -> {
5566-
request.setChunked(true).sendHead();
5566+
request.setChunked(true).writeHead();
55675567
request.response().compose(HttpClientResponse::body).onComplete(onSuccess(v -> {
55685568
vertx.setTimer(10, id -> request.end());
55695569
complete();
@@ -5593,7 +5593,7 @@ public void testFailPendingRequestAllocationWhenConnectionIsClosed() throws Exce
55935593
case 0:
55945594
assertTrue(ar.succeeded());
55955595
HttpClientRequest req = ar.result();
5596-
req.sendHead();
5596+
req.writeHead();
55975597
req.response().onComplete(onSuccess(resp -> {
55985598
complete();
55995599
}));

vertx-core/src/test/java/io/vertx/tests/http/Http2ClientTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers
12851285
complete();
12861286
}
12871287
})
1288-
.sendHead();
1288+
.writeHead();
12891289
}));
12901290
});
12911291
await();
@@ -1341,7 +1341,7 @@ public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers
13411341
complete();
13421342
}
13431343
})
1344-
.sendHead();
1344+
.writeHead();
13451345
}));
13461346
});
13471347
await();
@@ -1454,7 +1454,7 @@ public void test100Continue() throws Exception {
14541454
status.getAndIncrement();
14551455
req.end(Buffer.buffer("request-body"));
14561456
});
1457-
req.sendHead().onComplete(version -> {
1457+
req.writeHead().onComplete(version -> {
14581458
assertEquals(1, req.streamId());
14591459
});
14601460
}));
@@ -1586,7 +1586,7 @@ public void testServerCloseNetSocket() throws Exception {
15861586
}
15871587

15881588
@Test
1589-
public void testSendHeadersCompletionHandler() throws Exception {
1589+
public void testwriteHeadersCompletionHandler() throws Exception {
15901590
AtomicInteger status = new AtomicInteger();
15911591
server.requestHandler(req -> {
15921592
req.response().end();
@@ -1601,7 +1601,7 @@ public void testSendHeadersCompletionHandler() throws Exception {
16011601
testComplete();
16021602
});
16031603
}));
1604-
req.sendHead().onComplete(onSuccess(version -> {
1604+
req.writeHead().onComplete(onSuccess(version -> {
16051605
assertEquals(0, status.getAndIncrement());
16061606
assertSame(HttpVersion.HTTP_2, req.version());
16071607
req.end();
@@ -1642,7 +1642,7 @@ public void testUnknownFrame() throws Exception {
16421642
testComplete();
16431643
});
16441644
}));
1645-
req.sendHead().onComplete(onSuccess(version -> {
1645+
req.writeHead().onComplete(onSuccess(version -> {
16461646
assertSame(HttpVersion.HTTP_2, req.version());
16471647
req.writeCustomFrame(10, 253, expectedSend);
16481648
req.end();
@@ -1812,7 +1812,7 @@ private void testIdleTimeout(HttpServerOptions serverOptions, HttpClientOptions
18121812
.exceptionHandler(err -> {
18131813
complete();
18141814
});
1815-
req.sendHead();
1815+
req.writeHead();
18161816
}));
18171817
});
18181818
await();
@@ -2179,7 +2179,7 @@ public int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int
21792179
});
21802180
}));
21812181
req.setStreamPriority(requestStreamPriority);
2182-
req.sendHead().onComplete(h -> {
2182+
req.writeHead().onComplete(h -> {
21832183
req.setStreamPriority(requestStreamPriority2);
21842184
req.end();
21852185
});
@@ -2236,7 +2236,7 @@ public int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int
22362236
});
22372237
}));
22382238
req.setStreamPriority(streamPriority);
2239-
req.sendHead();
2239+
req.writeHead();
22402240
latch.future().onComplete(onSuccess(v -> {
22412241
req.setStreamPriority(streamPriority);
22422242
req.end();

vertx-core/src/test/java/io/vertx/tests/http/Http2Test.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void testServerResponseResetFromOtherThread() throws Exception {
141141
assertTrue(err instanceof StreamResetException);
142142
complete();
143143
})
144-
.sendHead();
144+
.writeHead();
145145
}));
146146
await();
147147
}
@@ -176,7 +176,7 @@ public void testClientRequestWriteFromOtherThread() throws Exception {
176176
}));
177177
req
178178
.setChunked(true)
179-
.sendHead();
179+
.writeHead();
180180
new Thread(() -> {
181181
try {
182182
awaitLatch(latch2); // The next write won't be buffered
@@ -498,7 +498,7 @@ public void testStreamWeightAndDependencyChange() throws Exception {
498498
complete();
499499
}));
500500
req
501-
.sendHead()
501+
.writeHead()
502502
.onComplete(h -> {
503503
req.setStreamPriority(new StreamPriority()
504504
.setDependency(requestStreamDependency2)
@@ -543,7 +543,7 @@ public void testServerStreamPriorityNoChange() throws Exception {
543543
.setWeight(weight)
544544
.setExclusive(exclusive));
545545
req
546-
.sendHead()
546+
.writeHead()
547547
.onComplete(h -> {
548548
req.setStreamPriority(new StreamPriority()
549549
.setDependency(dependency)
@@ -778,7 +778,7 @@ public void testClearTextUpgradeWithBodyTooLongFrameResponse() throws Exception
778778
testComplete();
779779
}
780780
});
781-
req.sendHead();
781+
req.writeHead();
782782
}));
783783
await();
784784
}
@@ -954,7 +954,7 @@ public void testStreamResetErrorMapping() throws Exception {
954954
testComplete();
955955
});
956956
// Force stream allocation
957-
req.sendHead().onComplete(onSuccess(v -> {
957+
req.writeHead().onComplete(onSuccess(v -> {
958958
req.reset(10);
959959
}));
960960
}));

vertx-core/src/test/java/io/vertx/tests/http/HttpClientTimeoutTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public void testHttpClientRequestTimeoutResetsTheConnection() throws Exception {
239239
req.response().onComplete(onFailure(err -> {
240240
complete();
241241
}));
242-
req.setChunked(true).sendHead().onComplete(onSuccess(version -> req.idleTimeout(500)));
242+
req.setChunked(true).writeHead().onComplete(onSuccess(version -> req.idleTimeout(500)));
243243
AtomicBoolean errored = new AtomicBoolean();
244244
req.exceptionHandler(err -> {
245245
if (errored.compareAndSet(false, true)) {
@@ -289,7 +289,7 @@ public void testResponseDataTimeout() throws Exception {
289289
complete();
290290
}
291291
});
292-
req.sendHead();
292+
req.writeHead();
293293
}));
294294
await();
295295
}

0 commit comments

Comments
 (0)