Files
boost_beast/include/beast/http/empty_body.hpp
T

76 lines
1.6 KiB
C++
Raw Normal View History

2016-04-19 20:29:16 -04:00
//
// Copyright (c) 2013-2016 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 <beast/core/error.hpp>
#include <beast/http/message.hpp>
#include <beast/http/resume_context.hpp>
#include <beast/core/detail/type_traits.hpp>
2016-04-19 20:29:16 -04:00
#include <boost/asio/buffer.hpp>
#include <boost/logic/tribool.hpp>
2016-04-19 20:29:16 -04:00
#include <memory>
#include <string>
namespace beast {
namespace http {
/** An empty content-body.
Meets the requirements of @b `Body`.
2016-04-19 20:29:16 -04:00
*/
struct empty_body
{
2016-04-22 19:02:07 -04:00
#if GENERATING_DOCS
/// The type of the `message::body` member
using value_type = void;
#else
struct value_type {};
#endif
#if GENERATING_DOCS
private:
#endif
2016-04-19 20:29:16 -04:00
struct writer
{
template<bool isRequest, class Fields>
2016-04-19 20:29:16 -04:00
explicit
writer(message<isRequest, empty_body, Fields> const& m) noexcept
2016-04-19 20:29:16 -04:00
{
beast::detail::ignore_unused(m);
2016-04-19 20:29:16 -04:00
}
void
2016-10-15 13:40:17 -04:00
init(error_code& ec) noexcept
2016-04-19 20:29:16 -04:00
{
beast::detail::ignore_unused(ec);
2016-04-19 20:29:16 -04:00
}
std::uint64_t
2016-10-15 13:40:17 -04:00
content_length() const noexcept
2016-04-19 20:29:16 -04:00
{
return 0;
}
2016-10-15 13:40:17 -04:00
template<class WriteFunction>
2016-04-19 20:29:16 -04:00
boost::tribool
2016-10-15 13:40:17 -04:00
write(resume_context&&, error_code&,
WriteFunction&& wf) noexcept
2016-04-19 20:29:16 -04:00
{
2016-10-15 13:40:17 -04:00
wf(boost::asio::null_buffers{});
2016-04-19 20:29:16 -04:00
return true;
}
};
};
} // http
} // beast
#endif