Skip to content

Commit

Permalink
Defer the creation of the response object (#2496)
Browse files Browse the repository at this point in the history
If there is no subscription we may not need this object.
  • Loading branch information
violetagg committed Sep 21, 2022
1 parent 1d3ebfd commit 5a644f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Expand Up @@ -772,13 +772,9 @@ final Mono<Void> send() {
if (!channel().isActive()) {
return Mono.error(AbortedException.beforeSend());
}
if (markSentHeaderAndBody()) {
HttpMessage request = newFullBodyMessage(Unpooled.EMPTY_BUFFER);
return FutureMono.deferFuture(() -> channel().writeAndFlush(request));
}
else {
return Mono.empty();
}
return FutureMono.deferFuture(() -> markSentHeaderAndBody() ?
channel().writeAndFlush(newFullBodyMessage(Unpooled.EMPTY_BUFFER)) :
channel().newSucceededFuture());
}

final void setNettyResponse(HttpResponse nettyResponse) {
Expand Down
Expand Up @@ -445,13 +445,9 @@ public HttpHeaders responseHeaders() {

@Override
public Mono<Void> send() {
if (markSentHeaderAndBody()) {
HttpMessage response = newFullBodyMessage(EMPTY_BUFFER);
return FutureMono.deferFuture(() -> channel().writeAndFlush(response));
}
else {
return Mono.empty();
}
return FutureMono.deferFuture(() -> markSentHeaderAndBody() ?
channel().writeAndFlush(newFullBodyMessage(EMPTY_BUFFER)) :
channel().newSucceededFuture());
}

@Override
Expand Down

0 comments on commit 5a644f7

Please sign in to comment.