Skip to content

Commit

Permalink
Fix a bug after removing content-length header in some reponses
Browse files Browse the repository at this point in the history
  • Loading branch information
an-tao committed Oct 1, 2024
1 parent 912f1d8 commit 21853b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/src/HttpResponseImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,19 @@ void HttpResponseImpl::makeHeaderString(trantor::MsgBuffer &buffer)
}
len = 0;
}
else if (sendfileName_.empty() && contentLengthIsAllowed())
else if (!contentLengthIsAllowed())
{
len = 0;
}
else if (sendfileName_.empty())
{
auto bodyLength = bodyPtr_ ? bodyPtr_->length() : 0;
len = snprintf(buffer.beginWrite(),
buffer.writableBytes(),
contentLengthFormatString<decltype(bodyLength)>(),
bodyLength);
}
else if (contentLengthIsAllowed())
else
{
auto bodyLength = sendfileRange_.second;
len = snprintf(buffer.beginWrite(),
Expand Down

0 comments on commit 21853b7

Please sign in to comment.