basic_parser: remove skip_ usage

This commit is contained in:
Mohammad Nejati
2024-08-21 18:29:09 +00:00
committed by Mohammad Nejati
parent b1f377b2eb
commit aefc564fa7
2 changed files with 2 additions and 8 deletions

View File

@@ -78,7 +78,6 @@ class basic_parser
std::uint64_t len0_ = 0; // content length if known std::uint64_t len0_ = 0; // content length if known
std::unique_ptr<char[]> buf_; // temp storage std::unique_ptr<char[]> buf_; // temp storage
std::size_t buf_len_ = 0; // size of buf_ std::size_t buf_len_ = 0; // size of buf_
std::size_t skip_ = 0; // resume search here
std::uint32_t header_limit_ = 8192; // max header size std::uint32_t header_limit_ = 8192; // max header size
unsigned short status_ = 0; // response status unsigned short status_ = 0; // response status
state state_ = state::nothing_yet; // initial state state state_ = state::nothing_yet; // initial state

View File

@@ -164,7 +164,6 @@ loop:
parse_chunk_header(p, n, ec); parse_chunk_header(p, n, ec);
if(ec) if(ec)
goto done; goto done;
BOOST_ASSERT(! skip_);
if(state_ != state::trailer_fields) if(state_ != state::trailer_fields)
break; break;
n = static_cast<std::size_t>(p1 - p); n = static_cast<std::size_t>(p1 - p);
@@ -584,7 +583,7 @@ parse_chunk_header(char const*& in,
auto p = in; auto p = in;
auto const pend = p + n; auto const pend = p + n;
if(n < skip_ + 2) if(n < 2)
{ {
BOOST_BEAST_ASSIGN_EC(ec, error::need_more); BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
@@ -601,17 +600,14 @@ parse_chunk_header(char const*& in,
} }
} }
auto const eol = find_eol(p + skip_, pend, ec); auto const eol = find_eol(p, pend, ec);
if(ec) if(ec)
return; return;
if(! eol) if(! eol)
{ {
BOOST_BEAST_ASSIGN_EC(ec, error::need_more); BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
if(p != pend)
skip_ = pend - p - 1;
return; return;
} }
skip_ = static_cast<std::size_t>(eol - p - 2);
std::uint64_t size; std::uint64_t size;
if(! parse_hex(p, size)) if(! parse_hex(p, size))
@@ -644,7 +640,6 @@ parse_chunk_header(char const*& in,
return; return;
len_ = size; len_ = size;
skip_ = 0;
in = eol; in = eol;
f_ |= flagExpectCRLF; f_ |= flagExpectCRLF;
if(size != 0) if(size != 0)