Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:30:17

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_HTTP_EMPTY_BODY_HPP
0011 #define BOOST_BEAST_HTTP_EMPTY_BODY_HPP
0012 
0013 #include <boost/beast/http/empty_body_fwd.hpp>
0014 
0015 #include <boost/beast/core/detail/config.hpp>
0016 #include <boost/beast/http/error.hpp>
0017 #include <boost/beast/http/message.hpp>
0018 #include <boost/optional.hpp>
0019 
0020 #include <cstdint>
0021 
0022 namespace boost {
0023 namespace beast {
0024 namespace http {
0025 
0026 /** An empty <em>Body</em>
0027 
0028     This body is used to represent messages which do not have a
0029     message body. If this body is used with a parser, and the
0030     parser encounters octets corresponding to a message body,
0031     the parser will fail with the error @ref http::unexpected_body.
0032 
0033     The Content-Length of this body is always 0.
0034 */
0035 struct empty_body
0036 {
0037     /** The type of container used for the body
0038 
0039         This determines the type of @ref message::body
0040         when this body type is used with a message container.
0041     */
0042     struct value_type
0043     {
0044     };
0045 
0046     /** Returns the payload size of the body
0047 
0048         When this body is used with @ref message::prepare_payload,
0049         the Content-Length will be set to the payload size, and
0050         any chunked Transfer-Encoding will be removed.
0051     */
0052     static
0053     std::uint64_t
0054     size(value_type)
0055     {
0056         return 0;
0057     }
0058 
0059     /** The algorithm for parsing the body
0060 
0061         Meets the requirements of <em>BodyReader</em>.
0062     */
0063 #if BOOST_BEAST_DOXYGEN
0064     using reader = __implementation_defined__;
0065 #else
0066     struct reader
0067     {
0068         template<bool isRequest, class Fields>
0069         explicit
0070         reader(header<isRequest, Fields>&, value_type&)
0071         {
0072         }
0073 
0074         void
0075         init(boost::optional<std::uint64_t> const&, error_code& ec)
0076         {
0077             ec = {};
0078         }
0079 
0080         template<class ConstBufferSequence>
0081         std::size_t
0082         put(ConstBufferSequence const&,
0083             error_code& ec)
0084         {
0085             BOOST_BEAST_ASSIGN_EC(ec, error::unexpected_body);
0086             return 0;
0087         }
0088 
0089         void
0090         finish(error_code& ec)
0091         {
0092             ec = {};
0093         }
0094     };
0095 #endif
0096 
0097     /** The algorithm for serializing the body
0098 
0099         Meets the requirements of <em>BodyWriter</em>.
0100     */
0101 #if BOOST_BEAST_DOXYGEN
0102     using writer = __implementation_defined__;
0103 #else
0104     struct writer
0105     {
0106         using const_buffers_type =
0107             net::const_buffer;
0108 
0109         template<bool isRequest, class Fields>
0110         explicit
0111         writer(header<isRequest, Fields> const&, value_type const&)
0112         {
0113         }
0114 
0115         void
0116         init(error_code& ec)
0117         {
0118             ec = {};
0119         }
0120 
0121         boost::optional<std::pair<const_buffers_type, bool>>
0122         get(error_code& ec)
0123         {
0124             ec = {};
0125             return boost::none;
0126         }
0127     };
0128 #endif
0129 };
0130 
0131 } // http
0132 } // beast
0133 } // boost
0134 
0135 #endif