Skip to content

Commit

Permalink
Fix for quarkusio#34632 to prevent race condition on adding headers i…
Browse files Browse the repository at this point in the history
…f already added
  • Loading branch information
Paul Carter-Brown committed Jul 17, 2023
1 parent d903356 commit 10ac0ea
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,12 @@ private void prepareWrite(ByteBuf buffer, boolean finished) throws IOException {
if (!committed) {
committed = true;
if (finished) {
if (buffer == null) {
context.serverResponse().setResponseHeader(HttpHeaderNames.CONTENT_LENGTH, "0");
} else {
context.serverResponse().setResponseHeader(HttpHeaderNames.CONTENT_LENGTH, "" + buffer.readableBytes());
if (context.serverResponse().getResponseHeader(HttpHeaderNames.CONTENT_LENGTH.toString()) == null) {
if (buffer == null) {
context.serverResponse().setResponseHeader(HttpHeaderNames.CONTENT_LENGTH, "0");
} else {
context.serverResponse().setResponseHeader(HttpHeaderNames.CONTENT_LENGTH, "" + buffer.readableBytes());
}
}
} else {
var contentLengthSet = contentLengthSet();
Expand Down

0 comments on commit 10ac0ea

Please sign in to comment.