diff --git a/CHANGELOG.md b/CHANGELOG.md index d7af4362..41aa4719 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 129: * Add autobahn test report to doc * Documentation tidying +* Fix prepare_payload: chunked is HTTP/1.1 -------------------------------------------------------------------------------- diff --git a/include/boost/beast/http/impl/message.ipp b/include/boost/beast/http/impl/message.ipp index d325b621..64d96eb6 100644 --- a/include/boost/beast/http/impl/message.ipp +++ b/include/boost/beast/http/impl/message.ipp @@ -382,7 +382,7 @@ prepare_payload(std::true_type) this->chunked(false); } } - else if(this->version() >= 11) + else if(this->version() == 11) { this->chunked(true); } @@ -398,19 +398,21 @@ message:: prepare_payload(std::false_type) { auto const n = payload_size(); - if((status_class(this->result()) == status_class::informational || + if( (! n || *n > 0) && ( + (status_class(this->result()) == status_class::informational || this->result() == status::no_content || - this->result() == status::not_modified)) + this->result() == status::not_modified))) { - if(! n || *n > 0) - // The response body MUST be empty for this case - BOOST_THROW_EXCEPTION(std::invalid_argument{ - "invalid response body"}); + // The response body MUST be empty for this case + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid response body"}); } if(n) this->content_length(n); - else + else if(this->version() == 11) this->chunked(true); + else + this->chunked(false); } //------------------------------------------------------------------------------