diff --git a/ircd/http.cc b/ircd/http.cc index 59c9fcc48..3ae900e2e 100644 --- a/ircd/http.cc +++ b/ircd/http.cc @@ -49,6 +49,8 @@ namespace ircd::http struct parser extern const parser; extern const std::unordered_map reason; + + [[noreturn]] void throw_error(const qi::expectation_failure &); } BOOST_FUSION_ADAPT_STRUCT @@ -618,22 +620,7 @@ try } catch(const qi::expectation_failure &e) { - const auto rule - { - ircd::string(e.what_) - }; - - throw error - { - code::BAD_REQUEST, fmt::snstringf - { - BUFSIZE, - "I require a valid HTTP %s. You sent %zu invalid characters starting with `%s'.", - between(rule, "<", ">"), - size_t(e.last - e.first), - string_view{e.first, e.last} - } - }; + throw_error(e); } ircd::http::line::response::response(const line &line) @@ -662,22 +649,7 @@ try } catch(const qi::expectation_failure &e) { - const auto rule - { - ircd::string(e.what_) - }; - - throw error - { - code::BAD_REQUEST, fmt::snstringf - { - BUFSIZE, - "I require a valid HTTP %s. You sent %zu invalid characters starting with `%s'.", - between(rule, "<", ">"), - size_t(e.last - e.first), - string_view{e.first, e.last} - } - }; + throw_error(e); } ircd::http::line::line(parse::capstan &pc) @@ -880,6 +852,26 @@ ircd::http::writeline(stream_buffer &write) }); } +void +ircd::http::throw_error(const qi::expectation_failure &e) +{ + const auto rule + { + ircd::string(e.what_) + }; + + throw error + { + code::BAD_REQUEST, fmt::snstringf + { + 512, "I require a valid HTTP %s. You sent %zu invalid characters starting with `%s'.", + between(rule, "<", ">"), + size_t(e.last - e.first), + string_view{e.first, e.last} + } + }; +} + ircd::http::error::error(const enum code &code, std::string content, const vector_view &headers)