diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a406048..54d0ab1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 224: * Remove extraneous error check in advanced-server-flex * Advanced servers use HTTP parser interfaces for reading +* Reusing an HTTP parser returns an error -------------------------------------------------------------------------------- diff --git a/doc/qbk/release_notes.qbk b/doc/qbk/release_notes.qbk index 864fc169..8a9d67c9 100644 --- a/doc/qbk/release_notes.qbk +++ b/doc/qbk/release_notes.qbk @@ -353,6 +353,8 @@ * ([issue 1460]) Large WebSocket Upgrade response no longer overflows +* Reusing an HTTP parser returns an error + * Handler bind wrappers use the associated allocator * `buffers_cat` diff --git a/include/boost/beast/http/error.hpp b/include/boost/beast/http/error.hpp index 8dc59053..1f4dfea2 100644 --- a/include/boost/beast/http/error.hpp +++ b/include/boost/beast/http/error.hpp @@ -144,7 +144,16 @@ enum class error bad_chunk_extension, /// An obs-fold exceeded an internal limit. - bad_obs_fold + bad_obs_fold, + + /** The parser is stale. + + This happens when attempting to re-use a parser that has + already completed parsing a message. Programs must construct + a new parser for each message. This can be easily done by + storing the parser in an boost or std::optional container. + */ + stale_parser }; } // http diff --git a/include/boost/beast/http/impl/error.ipp b/include/boost/beast/http/impl/error.ipp index bf15c690..e0167b30 100644 --- a/include/boost/beast/http/impl/error.ipp +++ b/include/boost/beast/http/impl/error.ipp @@ -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::stale_parser: return "stale parser"; default: return "beast.http error"; diff --git a/include/boost/beast/http/parser.hpp b/include/boost/beast/http/parser.hpp index 854d93bb..7a4e83e7 100644 --- a/include/boost/beast/http/parser.hpp +++ b/include/boost/beast/http/parser.hpp @@ -61,6 +61,7 @@ class parser message> m_; typename Body::reader rd_; bool rd_inited_ = false; + bool used_ = false; std::function