Skip to content

Commit

Permalink
Merge #3549 into 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Dec 17, 2024
2 parents d4e1196 + 9288524 commit ada11e0
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 @@ -567,8 +567,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 @@ -463,7 +463,9 @@ public NettyOutbound send(Publisher<? extends ByteBuf> 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)) {

ByteBufAllocator alloc = channel().alloc();
return new PostHeadersNettyOutbound(Flux.from(source)
Expand Down Expand Up @@ -498,7 +500,7 @@ public NettyOutbound send(Publisher<? extends ByteBuf> source) {
}
for (ByteBuf bb : list) {
if (log.isDebugEnabled()) {
log.debug(format(channel(), "Ignoring accumulated bytebuf on http GET {}"), bb);
log.debug(format(channel(), "Ignoring accumulated bytebuf on http {} {}"), method(), bb);
}
bb.release();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3594,24 +3594,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().retain()))
.handle((req, res) -> res.sendString(
Flux.concat(req.receive().retain().aggregate().asString().defaultIfEmpty("empty"),
Mono.just(" " + req.requestHeaders().get(HttpHeaderNames.CONTENT_LENGTH)))))
.bindNow();

Publisher<ByteBuf> body = chunked ?
Publisher<ByteBuf> body = "flux".equals(requestBodyType) ?
ByteBufFlux.fromString(Flux.just("d", "e", "l", "e", "t", "e")) :
ByteBufMono.fromString(Mono.just("delete"));
"mono".equals(requestBodyType) ? ByteBufMono.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 ada11e0

Please sign in to comment.