Fix erroneous error when HTTP body_limit is none

fixes #2070
closes #2073
This commit is contained in:
Richard Hodges
2020-08-28 12:23:40 +02:00
parent d04ff199bb
commit 9e6822773e
3 changed files with 24 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
Version XXX:
Version 301:
* Fix erroneous error when HTTP `body_limit` is `none`.
* Fix unreachable code warning with MSVC.
* Fix logic error in advance_server_flex.
* Fix file open with append_existing flag on posix.

View File

@@ -447,7 +447,8 @@ finish_header(error_code& ec, std::true_type)
}
else if(f_ & flagContentLength)
{
if(len_ > body_limit_)
if(body_limit_.has_value() &&
len_ > body_limit_)
{
ec = error::body_limit;
return;
@@ -511,7 +512,8 @@ finish_header(error_code& ec, std::false_type)
f_ |= flagHasBody;
state_ = state::body0;
if(len_ > body_limit_)
if(body_limit_.has_value() &&
len_ > body_limit_)
{
ec = error::body_limit;
return;

View File

@@ -1500,6 +1500,23 @@ public:
}
}
void
testUnlimitedBody()
{
const char data[] =
"POST / HTTP/1.1\r\n"
"Content-Length: 5\r\n"
"\r\n"
"*****";
test::fail_count fc(1000);
test_parser<true> p(fc);
p.body_limit(none);
error_code ec;
p.put(net::buffer(data, strlen(data)), ec);
BEAST_EXPECTS(!ec, ec.message());
}
//--------------------------------------------------------------------------
void
@@ -1528,6 +1545,7 @@ public:
testIssue1267();
testChunkedOverflow();
testChunkedBodySize();
testUnlimitedBody();
}
};