diff --git a/include/beast/http/empty_body.hpp b/include/beast/http/empty_body.hpp index d1b2b83f..71c1bf72 100644 --- a/include/beast/http/empty_body.hpp +++ b/include/beast/http/empty_body.hpp @@ -16,11 +16,15 @@ namespace beast { namespace http { -/** An empty message body +/** An empty message body. - Meets the requirements of @b Body. + This body is used to represent messages which do not have a + message body. If this body is used with a parser, and the + parser encounters octets corresponding to a message body, + the parser will fail with the error @ref http::unexpected_body. - @note This body type may only be written, not read. + Meets the requirements of @b Body. The Content-Length of this + body is always 0. */ struct empty_body { @@ -91,7 +95,7 @@ struct empty_body put(ConstBufferSequence const&, error_code& ec) { - ec = error::missing_body; + ec = error::unexpected_body; } void diff --git a/include/beast/http/error.hpp b/include/beast/http/error.hpp index dd5c2af0..70813f94 100644 --- a/include/beast/http/error.hpp +++ b/include/beast/http/error.hpp @@ -47,7 +47,7 @@ enum class error */ need_more, - /** The message container has no body. + /** An unexpected body was encountered during parsing. This error is returned when attempting to parse body octets into a message container which has the @@ -55,7 +55,7 @@ enum class error @see @ref empty_body */ - missing_body, + unexpected_body, /** Additional buffers are required. diff --git a/test/http/error.cpp b/test/http/error.cpp index bfff3dcc..a8cc3477 100644 --- a/test/http/error.cpp +++ b/test/http/error.cpp @@ -39,7 +39,10 @@ public: check("http", error::end_of_stream); check("http", error::partial_message); check("http", error::need_more); + check("http", error::unexpected_body); + check("http", error::need_buffer); check("http", error::buffer_overflow); + check("http", error::bad_line_ending); check("http", error::bad_method); check("http", error::bad_path);