2017-05-08 12:41:45 -07:00
|
|
|
//
|
|
|
|
|
// 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 <beast/config.hpp>
|
2017-05-31 08:01:55 -07:00
|
|
|
#include <beast/http/error.hpp>
|
2017-05-08 12:41:45 -07:00
|
|
|
#include <beast/http/message.hpp>
|
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
|
|
|
|
|
|
namespace beast {
|
|
|
|
|
namespace http {
|
|
|
|
|
|
2017-06-04 15:05:23 -07:00
|
|
|
/** An empty message body.
|
2017-05-08 12:41:45 -07:00
|
|
|
|
2017-06-04 15:05:23 -07:00
|
|
|
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.
|
2017-05-08 12:41:45 -07:00
|
|
|
|
2017-06-04 15:05:23 -07:00
|
|
|
Meets the requirements of @b Body. The Content-Length of this
|
|
|
|
|
body is always 0.
|
2017-05-08 12:41:45 -07:00
|
|
|
*/
|
|
|
|
|
struct empty_body
|
|
|
|
|
{
|
|
|
|
|
/// The type of the body member when used in a message.
|
|
|
|
|
struct value_type
|
|
|
|
|
{
|
2017-05-31 08:01:55 -07:00
|
|
|
// VFALCO We could stash boost::optional<std::uint64_t>
|
|
|
|
|
// for the content length here, set on init()
|
2017-05-08 12:41:45 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#if BEAST_DOXYGEN
|
2017-05-28 09:05:29 -07:00
|
|
|
/// The algorithm to obtain buffers representing the body
|
|
|
|
|
using reader = implementation_defined;
|
2017-05-08 12:41:45 -07:00
|
|
|
#else
|
2017-05-28 09:05:29 -07:00
|
|
|
struct reader
|
2017-05-08 12:41:45 -07:00
|
|
|
{
|
|
|
|
|
using is_deferred = std::false_type;
|
|
|
|
|
|
|
|
|
|
using const_buffers_type =
|
|
|
|
|
boost::asio::null_buffers;
|
|
|
|
|
|
|
|
|
|
template<bool isRequest, class Fields>
|
|
|
|
|
explicit
|
2017-05-28 09:05:29 -07:00
|
|
|
reader(message<
|
2017-05-08 12:41:45 -07:00
|
|
|
isRequest, empty_body, Fields> const&)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
init(error_code&)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::uint64_t
|
|
|
|
|
content_length() const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boost::optional<std::pair<const_buffers_type, bool>>
|
|
|
|
|
get(error_code& ec)
|
|
|
|
|
{
|
|
|
|
|
return boost::none;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
#endif
|
2017-05-31 08:01:55 -07:00
|
|
|
|
|
|
|
|
#if BEAST_DOXYGEN
|
|
|
|
|
/// The algorithm used store buffers in this body
|
|
|
|
|
using writer = implementation_defined;
|
|
|
|
|
#else
|
|
|
|
|
struct writer
|
|
|
|
|
{
|
|
|
|
|
template<bool isRequest, class Fields>
|
|
|
|
|
explicit
|
|
|
|
|
writer(message<isRequest, empty_body, Fields>& msg)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
init(boost::optional<std::uint64_t> const&,
|
|
|
|
|
error_code&)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<class ConstBufferSequence>
|
|
|
|
|
void
|
|
|
|
|
put(ConstBufferSequence const&,
|
|
|
|
|
error_code& ec)
|
|
|
|
|
{
|
2017-06-04 15:05:23 -07:00
|
|
|
ec = error::unexpected_body;
|
2017-05-31 08:01:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
finish(error_code&)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
#endif
|
2017-05-08 12:41:45 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // http
|
|
|
|
|
} // beast
|
|
|
|
|
|
|
|
|
|
#endif
|