Add multiple content length error

fix #2468
This commit is contained in:
alandefreitas
2022-10-02 20:04:46 +08:00
committed by Klemens Morgenstern
parent b4e0f0d560
commit 5866e50438
6 changed files with 13 additions and 3 deletions
+3
View File
@@ -146,6 +146,9 @@ enum class error
/// An obs-fold exceeded an internal limit.
bad_obs_fold,
/// The response contains multiple and conflicting Content-Length.
multiple_content_length,
/** The parser is stale.
This happens when attempting to re-use a parser that has
@@ -809,6 +809,11 @@ do_field(field f,
ec = error::bad_content_length;
};
auto multiple_content_length = [&ec]
{
ec = error::multiple_content_length;
};
// conflicting field
if(f_ & flagChunked)
return bad_content_length();
@@ -831,7 +836,7 @@ do_field(field f,
if (existing.has_value())
{
if (v != *existing)
return bad_content_length();
return multiple_content_length();
}
else
{
+1
View File
@@ -55,6 +55,7 @@ public:
case error::bad_chunk: return "bad chunk";
case error::bad_chunk_extension: return "bad chunk extension";
case error::bad_obs_fold: return "bad obs-fold";
case error::multiple_content_length: return "multiple Content-Length";
case error::stale_parser: return "stale parser";
case error::short_read: return "unexpected eof in body";