// // Copyright (c) 2013-2017 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) // #ifndef BEAST_HTTP_EMPTY_BODY_HPP #define BEAST_HTTP_EMPTY_BODY_HPP #include #include #include #include namespace beast { namespace http { /** An empty message 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. Meets the requirements of @b Body. The Content-Length of this body is always 0. */ struct empty_body { /// The type of the body member when used in a message. struct value_type { // VFALCO We could stash boost::optional // for the content length here, set on init() }; #if BEAST_DOXYGEN /// The algorithm to obtain buffers representing the body using reader = implementation_defined; #else struct reader { using is_deferred = std::false_type; using const_buffers_type = boost::asio::null_buffers; template explicit reader(message< isRequest, empty_body, Fields> const&) { } void init(error_code&) { } std::uint64_t content_length() const { return 0; } boost::optional> get(error_code& ec) { return boost::none; } }; #endif #if BEAST_DOXYGEN /// The algorithm used store buffers in this body using writer = implementation_defined; #else struct writer { template explicit writer(message& msg) { } void init(boost::optional const&, error_code&) { } template void put(ConstBufferSequence const&, error_code& ec) { ec = error::unexpected_body; } void finish(error_code&) { } }; #endif }; } // http } // beast #endif