123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849 |
- //
- // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
- //
- // Distributed under the Boost Software License, Version 1.0. (See accompanying
- // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- //
- // Official repository: https://github.com/boostorg/beast
- //
- #ifndef BOOST_BEAST_HTTP_DETAIL_BASIC_PARSER_IPP
- #define BOOST_BEAST_HTTP_DETAIL_BASIC_PARSER_IPP
- #include <boost/beast/http/detail/basic_parser.hpp>
- #include <limits>
- namespace boost {
- namespace beast {
- namespace http {
- namespace detail {
- char const*
- basic_parser_base::
- trim_front(char const* it, char const* end)
- {
- while(it != end)
- {
- if(*it != ' ' && *it != '\t')
- break;
- ++it;
- }
- return it;
- }
- char const*
- basic_parser_base::
- trim_back(
- char const* it, char const* first)
- {
- while(it != first)
- {
- auto const c = it[-1];
- if(c != ' ' && c != '\t')
- break;
- --it;
- }
- return it;
- }
- bool
- basic_parser_base::
- is_pathchar(char c)
- {
- // VFALCO This looks the same as the one below...
- // TEXT = <any OCTET except CTLs, and excluding LWS>
- static bool constexpr tab[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 32
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 48
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, // 112
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 128
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 144
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 160
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 176
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 192
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 208
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 224
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 240
- };
- return tab[static_cast<unsigned char>(c)];
- }
- bool
- basic_parser_base::
- unhex(unsigned char& d, char c)
- {
- static signed char constexpr tab[256] = {
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 0
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 16
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 32
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, // 48
- -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 64
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 80
- -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 96
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 112
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 128
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 144
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 160
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 176
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 192
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 208
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 224
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 // 240
- };
- d = static_cast<unsigned char>(
- tab[static_cast<unsigned char>(c)]);
- return d != static_cast<unsigned char>(-1);
- }
- //--------------------------------------------------------------------------
- std::pair<char const*, bool>
- basic_parser_base::
- find_fast(
- char const* buf,
- char const* buf_end,
- char const* ranges,
- size_t ranges_size)
- {
- bool found = false;
- boost::ignore_unused(buf_end, ranges, ranges_size);
- return {buf, found};
- }
- // VFALCO Can SIMD help this?
- char const*
- basic_parser_base::
- find_eol(
- char const* it, char const* last,
- error_code& ec)
- {
- for(;;)
- {
- if(it == last)
- {
- ec = {};
- return nullptr;
- }
- if(*it == '\r')
- {
- if(++it == last)
- {
- ec = {};
- return nullptr;
- }
- if(*it != '\n')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_line_ending);
- return nullptr;
- }
- ec = {};
- return ++it;
- }
- // VFALCO Should we handle the legacy case
- // for lines terminated with a single '\n'?
- ++it;
- }
- }
- bool
- basic_parser_base::
- parse_dec(
- string_view s,
- std::uint64_t& v)
- {
- char const* it = s.data();
- char const* last = it + s.size();
- if(it == last)
- return false;
- std::uint64_t tmp = 0;
- do
- {
- if((! is_digit(*it)) ||
- tmp > (std::numeric_limits<std::uint64_t>::max)() / 10)
- return false;
- tmp *= 10;
- std::uint64_t const d = *it - '0';
- if((std::numeric_limits<std::uint64_t>::max)() - tmp < d)
- return false;
- tmp += d;
- }
- while(++it != last);
- v = tmp;
- return true;
- }
- bool
- basic_parser_base::
- parse_hex(char const*& it, std::uint64_t& v)
- {
- unsigned char d;
- if(! unhex(d, *it))
- return false;
- std::uint64_t tmp = 0;
- do
- {
- if(tmp > (std::numeric_limits<std::uint64_t>::max)() / 16)
- return false;
- tmp *= 16;
- if((std::numeric_limits<std::uint64_t>::max)() - tmp < d)
- return false;
- tmp += d;
- }
- while(unhex(d, *++it));
- v = tmp;
- return true;
- }
- char const*
- basic_parser_base::
- find_eom(char const* p, char const* last)
- {
- for(;;)
- {
- if(p + 4 > last)
- return nullptr;
- if(p[3] != '\n')
- {
- if(p[3] == '\r')
- ++p;
- else
- p += 4;
- }
- else if(p[2] != '\r')
- {
- p += 4;
- }
- else if(p[1] != '\n')
- {
- p += 2;
- }
- else if(p[0] != '\r')
- {
- p += 2;
- }
- else
- {
- return p + 4;
- }
- }
- }
- //--------------------------------------------------------------------------
- char const*
- basic_parser_base::
- parse_token_to_eol(
- char const* p,
- char const* last,
- char const*& token_last,
- error_code& ec)
- {
- for(;; ++p)
- {
- if(p >= last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return p;
- }
- if(BOOST_UNLIKELY(! is_print(*p)))
- if((BOOST_LIKELY(static_cast<
- unsigned char>(*p) < '\040') &&
- BOOST_LIKELY(*p != 9)) ||
- BOOST_UNLIKELY(*p == 127))
- goto found_control;
- }
- found_control:
- if(BOOST_LIKELY(*p == '\r'))
- {
- if(++p >= last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return last;
- }
- if(*p++ != '\n')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_line_ending);
- return last;
- }
- token_last = p - 2;
- }
- #if 0
- // VFALCO This allows `\n` by itself
- // to terminate a line
- else if(*p == '\n')
- {
- token_last = p;
- ++p;
- }
- #endif
- else
- {
- // invalid character
- return nullptr;
- }
- return p;
- }
- bool
- basic_parser_base::
- parse_crlf(char const*& it)
- {
- if( it[0] != '\r' || it[1] != '\n')
- return false;
- it += 2;
- return true;
- }
- void
- basic_parser_base::
- parse_method(
- char const*& it, char const* last,
- string_view& result, error_code& ec)
- {
- // parse token SP
- auto const first = it;
- for(;; ++it)
- {
- if(it + 1 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(! detail::is_token_char(*it))
- break;
- }
- if(it + 1 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(*it != ' ')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_method);
- return;
- }
- if(it == first)
- {
- // cannot be empty
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_method);
- return;
- }
- result = make_string(first, it++);
- }
- void
- basic_parser_base::
- parse_target(
- char const*& it, char const* last,
- string_view& result, error_code& ec)
- {
- // parse target SP
- auto const first = it;
- for(;; ++it)
- {
- if(it + 1 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(! is_pathchar(*it))
- break;
- }
- if(it + 1 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(*it != ' ')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_target);
- return;
- }
- if(it == first)
- {
- // cannot be empty
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_target);
- return;
- }
- result = make_string(first, it++);
- }
- void
- basic_parser_base::
- parse_version(
- char const*& it, char const* last,
- int& result, error_code& ec)
- {
- if(it + 8 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(*it++ != 'H')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
- return;
- }
- if(*it++ != 'T')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
- return;
- }
- if(*it++ != 'T')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
- return;
- }
- if(*it++ != 'P')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
- return;
- }
- if(*it++ != '/')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
- return;
- }
- if(! is_digit(*it))
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
- return;
- }
- result = 10 * (*it++ - '0');
- if(*it++ != '.')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
- return;
- }
- if(! is_digit(*it))
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
- return;
- }
- result += *it++ - '0';
- }
- void
- basic_parser_base::
- parse_status(
- char const*& it, char const* last,
- unsigned short& result, error_code& ec)
- {
- // parse 3(digit) SP
- if(it + 4 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(! is_digit(*it))
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_status);
- return;
- }
- result = 100 * (*it++ - '0');
- if(! is_digit(*it))
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_status);
- return;
- }
- result += 10 * (*it++ - '0');
- if(! is_digit(*it))
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_status);
- return;
- }
- result += *it++ - '0';
- if(*it++ != ' ')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_status);
- return;
- }
- }
- void
- basic_parser_base::
- parse_reason(
- char const*& it, char const* last,
- string_view& result, error_code& ec)
- {
- auto const first = it;
- char const* token_last = nullptr;
- auto p = parse_token_to_eol(
- it, last, token_last, ec);
- if(ec)
- return;
- if(! p)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_reason);
- return;
- }
- result = make_string(first, token_last);
- it = p;
- }
- void
- basic_parser_base::
- parse_field(
- char const*& p,
- char const* last,
- string_view& name,
- string_view& value,
- beast::detail::char_buffer<max_obs_fold>& buf,
- error_code& ec)
- {
- /* header-field = field-name ":" OWS field-value OWS
- field-name = token
- field-value = *( field-content / obs-fold )
- field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
- field-vchar = VCHAR / obs-text
- obs-fold = CRLF 1*( SP / HTAB )
- ; obsolete line folding
- ; see Section 3.2.4
- token = 1*<any CHAR except CTLs or separators>
- CHAR = <any US-ASCII character (octets 0 - 127)>
- sep = "(" | ")" | "<" | ">" | "@"
- | "," | ";" | ":" | "\" | <">
- | "/" | "[" | "]" | "?" | "="
- | "{" | "}" | SP | HT
- */
- static char const* is_token =
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
- "\0\1\0\1\1\1\1\1\0\0\1\1\0\1\1\0\1\1\1\1\1\1\1\1\1\1\0\0\0\0\0\0"
- "\0\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\0\0\1\1"
- "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\1\0\1\0"
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
- "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
- // name
- BOOST_ALIGNMENT(16) static const char ranges1[] =
- "\x00 " /* control chars and up to SP */
- "\"\"" /* 0x22 */
- "()" /* 0x28,0x29 */
- ",," /* 0x2c */
- "//" /* 0x2f */
- ":@" /* 0x3a-0x40 */
- "[]" /* 0x5b-0x5d */
- "{\377"; /* 0x7b-0xff */
- auto first = p;
- bool found;
- std::tie(p, found) = find_fast(
- p, last, ranges1, sizeof(ranges1)-1);
- if(! found && p >= last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- for(;;)
- {
- if(*p == ':')
- break;
- if(! is_token[static_cast<
- unsigned char>(*p)])
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_field);
- return;
- }
- ++p;
- if(p >= last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- }
- if(p == first)
- {
- // empty name
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_field);
- return;
- }
- name = make_string(first, p);
- ++p; // eat ':'
- char const* token_last = nullptr;
- for(;;)
- {
- // eat leading ' ' and '\t'
- for(;;++p)
- {
- if(p + 1 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(! (*p == ' ' || *p == '\t'))
- break;
- }
- // parse to CRLF
- first = p;
- p = parse_token_to_eol(p, last, token_last, ec);
- if(ec)
- return;
- if(! p)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_value);
- return;
- }
- // Look 1 char past the CRLF to handle obs-fold.
- if(p + 1 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- token_last =
- trim_back(token_last, first);
- if(*p != ' ' && *p != '\t')
- {
- value = make_string(first, token_last);
- return;
- }
- ++p;
- if(token_last != first)
- break;
- }
- buf.clear();
- if (!buf.try_append(first, token_last))
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::header_limit);
- return;
- }
- BOOST_ASSERT(! buf.empty());
- for(;;)
- {
- // eat leading ' ' and '\t'
- for(;;++p)
- {
- if(p + 1 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(! (*p == ' ' || *p == '\t'))
- break;
- }
- // parse to CRLF
- first = p;
- p = parse_token_to_eol(p, last, token_last, ec);
- if(ec)
- return;
- if(! p)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_value);
- return;
- }
- // Look 1 char past the CRLF to handle obs-fold.
- if(p + 1 > last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- token_last = trim_back(token_last, first);
- if(first != token_last)
- {
- if (!buf.try_push_back(' ') ||
- !buf.try_append(first, token_last))
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::header_limit);
- return;
- }
- }
- if(*p != ' ' && *p != '\t')
- {
- value = {buf.data(), buf.size()};
- return;
- }
- ++p;
- }
- }
- void
- basic_parser_base::
- parse_chunk_extensions(
- char const*& it,
- char const* last,
- error_code& ec)
- {
- /*
- chunk-ext = *( BWS ";" BWS chunk-ext-name [ BWS "=" BWS chunk-ext-val ] )
- BWS = *( SP / HTAB ) ; "Bad White Space"
- chunk-ext-name = token
- chunk-ext-val = token / quoted-string
- token = 1*tchar
- quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
- qdtext = HTAB / SP / "!" / %x23-5B ; '#'-'[' / %x5D-7E ; ']'-'~' / obs-text
- quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
- obs-text = %x80-FF
- https://www.rfc-editor.org/errata_search.php?rfc=7230&eid=4667
- */
- loop:
- if(it == last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(*it != ' ' && *it != '\t' && *it != ';')
- return;
- // BWS
- if(*it == ' ' || *it == '\t')
- {
- for(;;)
- {
- ++it;
- if(it == last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(*it != ' ' && *it != '\t')
- break;
- }
- }
- // ';'
- if(*it != ';')
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::bad_chunk_extension);
- return;
- }
- semi:
- ++it; // skip ';'
- // BWS
- for(;;)
- {
- if(it == last)
- {
- BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
- return;
- }
- if(*it != ' ' && *it != '\t')
- break;
- ++it;
- }
- // chunk-ext-name
- if(! detail::is_token_char(*it))
- {
- ec = error::bad_chunk_extension;
- return;
- }
- for(;;)
- {
- ++it;
- if(it == last)
- {
- ec = error::need_more;
- return;
- }
- if(! detail::is_token_char(*it))
- break;
- }
- // BWS [ ";" / "=" ]
- {
- bool bws;
- if(*it == ' ' || *it == '\t')
- {
- for(;;)
- {
- ++it;
- if(it == last)
- {
- ec = error::need_more;
- return;
- }
- if(*it != ' ' && *it != '\t')
- break;
- }
- bws = true;
- }
- else
- {
- bws = false;
- }
- if(*it == ';')
- goto semi;
- if(*it != '=')
- {
- if(bws)
- ec = error::bad_chunk_extension;
- return;
- }
- ++it; // skip '='
- }
- // BWS
- for(;;)
- {
- if(it == last)
- {
- ec = error::need_more;
- return;
- }
- if(*it != ' ' && *it != '\t')
- break;
- ++it;
- }
- // chunk-ext-val
- if(*it != '"')
- {
- // token
- if(! detail::is_token_char(*it))
- {
- ec = error::bad_chunk_extension;
- return;
- }
- for(;;)
- {
- ++it;
- if(it == last)
- {
- ec = error::need_more;
- return;
- }
- if(! detail::is_token_char(*it))
- break;
- }
- }
- else
- {
- // quoted-string
- for(;;)
- {
- ++it;
- if(it == last)
- {
- ec = error::need_more;
- return;
- }
- if(*it == '"')
- break;
- if(*it == '\\')
- {
- ++it;
- if(it == last)
- {
- ec = error::need_more;
- return;
- }
- }
- }
- ++it;
- }
- goto loop;
- }
- } // detail
- } // http
- } // beast
- } // boost
- #endif
|