Skip to content

Commit

Permalink
Revert "Remove content-length header from 101 Switching Protocols res…
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Bleis committed Oct 1, 2024
1 parent 671692e commit f808714
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 53 deletions.
5 changes: 2 additions & 3 deletions lib/src/HttpResponseImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ void HttpResponseImpl::makeHeaderString(trantor::MsgBuffer &buffer)
statusCode_);
}
}

buffer.hasWritten(len);

if (!statusMessage_.empty())
Expand All @@ -538,15 +537,15 @@ void HttpResponseImpl::makeHeaderString(trantor::MsgBuffer &buffer)
}
len = 0;
}
else if (sendfileName_.empty() && contentLengthIsAllowed())
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
10 changes: 0 additions & 10 deletions lib/src/HttpResponseImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,16 +537,6 @@ class DROGON_EXPORT HttpResponseImpl : public HttpResponse
{
statusMessage_ = message;
}

bool contentLengthIsAllowed()
{
int statusCode =
customStatusCode_ >= 0 ? customStatusCode_ : statusCode_;

// return false if status code is 1xx or 204
return (statusCode >= k200OK || statusCode < k100Continue) &&
statusCode != k204NoContent;
}
};

using HttpResponseImplPtr = std::shared_ptr<HttpResponseImpl>;
Expand Down
40 changes: 0 additions & 40 deletions lib/tests/unittests/WebsocketResponseTest.cc

This file was deleted.

0 comments on commit f808714

Please sign in to comment.