forked from boostorg/beast
Ignore Content-Length in some cases:
fix #692 The value of Content-Length is not checked for limits when the semantics of an HTTP response indicate that the message has no body. For example, when status is 101.
This commit is contained in:
@@ -532,6 +532,11 @@ finish_header(error_code& ec, std::true_type)
|
||||
}
|
||||
else if(f_ & flagContentLength)
|
||||
{
|
||||
if(len_ > body_limit_)
|
||||
{
|
||||
ec = error::body_limit;
|
||||
return;
|
||||
}
|
||||
if(len_ > 0)
|
||||
{
|
||||
f_ |= flagHasBody;
|
||||
@@ -578,12 +583,20 @@ finish_header(error_code& ec, std::false_type)
|
||||
status_ == 204 || // No Content
|
||||
status_ == 304) // Not Modified
|
||||
{
|
||||
// VFALCO Content-Length may be present, but we
|
||||
// treat the message as not having a body.
|
||||
// https://github.com/boostorg/beast/issues/692
|
||||
state_ = state::complete;
|
||||
return;
|
||||
}
|
||||
|
||||
if(f_ & flagContentLength)
|
||||
{
|
||||
if(len_ > body_limit_)
|
||||
{
|
||||
ec = error::body_limit;
|
||||
return;
|
||||
}
|
||||
if(len_ > 0)
|
||||
{
|
||||
f_ |= flagHasBody;
|
||||
@@ -876,12 +889,6 @@ do_field(field f,
|
||||
return;
|
||||
}
|
||||
|
||||
if(v > body_limit_)
|
||||
{
|
||||
ec = error::body_limit;
|
||||
return;
|
||||
}
|
||||
|
||||
ec.assign(0, ec.category());
|
||||
len_ = v;
|
||||
f_ |= flagContentLength;
|
||||
|
||||
Reference in New Issue
Block a user