Skip to content

Commit

Permalink
Merge #3549 into 2.0.0-M4
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Dec 17, 2024
2 parents 2d21d25 + ada11e0 commit b6abd0d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,9 @@ Publisher<Void> requestWithBody(HttpClientOperations ch) {
ch.followRedirectPredicate(followRedirectPredicate);

if (!Objects.equals(method, HttpMethod.GET) &&
!Objects.equals(method, HttpMethod.HEAD) &&
!headers.contains(HttpHeaderNames.CONTENT_LENGTH)) {
!Objects.equals(method, HttpMethod.HEAD) &&
!Objects.equals(method, HttpMethod.DELETE) &&
!headers.contains(HttpHeaderNames.CONTENT_LENGTH)) {
ch.chunkedTransfer(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ public NettyOutbound send(Publisher<? extends Buffer> source) {
if (source instanceof Mono) {
return super.send(source);
}
if (Objects.equals(method(), HttpMethod.GET) || Objects.equals(method(), HttpMethod.HEAD)) {
if (Objects.equals(method(), HttpMethod.GET) ||
Objects.equals(method(), HttpMethod.HEAD) ||
Objects.equals(method(), HttpMethod.DELETE)) {

return new PostHeadersNettyOutbound(Flux.from(source)
.collectList()
Expand Down Expand Up @@ -454,7 +456,7 @@ public NettyOutbound send(Publisher<? extends Buffer> source) {
}
for (Buffer bb : list) {
if (log.isDebugEnabled()) {
log.debug(format(channel(), "Ignoring accumulated buffer on http GET {}"), bb);
log.debug(format(channel(), "Ignoring accumulated buffer on http {} {}"), method(), bb);
}
bb.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3515,24 +3515,26 @@ void testIssue3416() {
}

@ParameterizedTest
@ValueSource(booleans = {true, false})
void testDeleteMethod(boolean chunked) {
@ValueSource(strings = {"mono", "flux", "empty"})
void testDeleteMethod(String requestBodyType) {
disposableServer =
createServer()
.handle((req, res) -> res.send(req.receive().transferOwnership()))
.handle((req, res) -> res.sendString(
Flux.concat(req.receive().aggregate().asString().defaultIfEmpty("empty"),
Mono.just(" " + req.requestHeaders().get(HttpHeaderNames.CONTENT_LENGTH)))))
.bindNow();

Publisher<Buffer> body = chunked ?
Publisher<Buffer> body = "flux".equals(requestBodyType) ?
BufferFlux.fromString(Flux.just("d", "e", "l", "e", "t", "e")) :
BufferMono.fromString(Mono.just("delete"));
"mono".equals(requestBodyType) ? BufferMono.fromString(Mono.just("delete")) : Mono.empty();

createClient(disposableServer.port())
.delete()
.uri("/")
.send(body)
.responseSingle((res, bytes) -> bytes.asString())
.as(StepVerifier::create)
.expectNext("delete")
.expectNext("empty".equals(requestBodyType) ? "empty 0" : "delete 6")
.expectComplete()
.verify(Duration.ofSeconds(5));
}
Expand Down

0 comments on commit b6abd0d

Please sign in to comment.