diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a0820a..5311cfd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 226: + +* Support -fno-exceptions + +-------------------------------------------------------------------------------- + Version 225: * Tidy up an unused function diff --git a/include/boost/beast/_experimental/test/impl/stream.ipp b/include/boost/beast/_experimental/test/impl/stream.ipp index b1dec0c4..665221c1 100644 --- a/include/boost/beast/_experimental/test/impl/stream.ipp +++ b/include/boost/beast/_experimental/test/impl/stream.ipp @@ -86,8 +86,8 @@ void stream::initiate_read( ++in_->nread; if(in_->op != nullptr) - throw std::logic_error( - "in_->op != nullptr"); + BOOST_THROW_EXCEPTION( + std::logic_error{"in_->op != nullptr"}); // test failure error_code ec; diff --git a/include/boost/beast/http/detail/basic_parser.hpp b/include/boost/beast/http/detail/basic_parser.hpp index d43c92c6..c1272947 100644 --- a/include/boost/beast/http/detail/basic_parser.hpp +++ b/include/boost/beast/http/detail/basic_parser.hpp @@ -674,7 +674,9 @@ struct basic_parser_base buf.resize(0); buf.append(first, token_last); BOOST_ASSERT(! buf.empty()); +#ifndef BOOST_NO_EXCEPTIONS try +#endif { for(;;) { @@ -719,11 +721,13 @@ struct basic_parser_base ++p; } } +#ifndef BOOST_NO_EXCEPTIONS catch(std::length_error const&) { ec = error::header_limit; return; } +#endif } void diff --git a/include/boost/beast/http/impl/fields.hpp b/include/boost/beast/http/impl/fields.hpp index 784e5115..77f151fe 100644 --- a/include/boost/beast/http/impl/fields.hpp +++ b/include/boost/beast/http/impl/fields.hpp @@ -1048,6 +1048,7 @@ set_chunked_impl(bool value) // filter "chunked" if(it == end()) return; +#ifndef BOOST_NO_EXCEPTIONS try { static_string buf; @@ -1062,6 +1063,7 @@ set_chunked_impl(bool value) erase(field::transfer_encoding); } catch(std::length_error const&) +#endif { #ifdef BOOST_BEAST_HTTP_NO_FIELDS_BASIC_STRING_ALLOCATOR // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437 @@ -1108,6 +1110,7 @@ set_keep_alive_impl( { // VFALCO What about Proxy-Connection ? auto const value = (*this)[field::connection]; +#ifndef BOOST_NO_EXCEPTIONS try { static_string buf; @@ -1119,6 +1122,7 @@ set_keep_alive_impl( set(field::connection, buf); } catch(std::length_error const&) +#endif { #ifdef BOOST_BEAST_HTTP_NO_FIELDS_BASIC_STRING_ALLOCATOR // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437 diff --git a/include/boost/beast/http/parser.hpp b/include/boost/beast/http/parser.hpp index 7a4e83e7..cd427e01 100644 --- a/include/boost/beast/http/parser.hpp +++ b/include/boost/beast/http/parser.hpp @@ -350,18 +350,11 @@ private: } used_ = true; - try - { - m_.target(target); - if(method != verb::unknown) - m_.method(method); - else - m_.method_string(method_str); - } - catch(std::bad_alloc const&) - { - ec = error::bad_alloc; - } + m_.target(target); + if(method != verb::unknown) + m_.method(method); + else + m_.method_string(method_str); m_.version(version); } @@ -409,14 +402,7 @@ private: m_.result(code); m_.version(version); - try - { - m_.reason(reason); - } - catch(std::bad_alloc const&) - { - ec = error::bad_alloc; - } + m_.reason(reason); } void @@ -443,16 +429,9 @@ private: field name, string_view name_string, string_view value, - error_code& ec) override + error_code&) override { - try - { - m_.insert(name, name_string, value); - } - catch(std::bad_alloc const&) - { - ec = error::bad_alloc; - } + m_.insert(name, name_string, value); } void