2017-05-08 12:41:45 -07:00
|
|
|
//
|
2019-02-21 07:00:31 -08:00
|
|
|
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
2017-05-08 12:41:45 -07:00
|
|
|
//
|
|
|
|
|
// 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)
|
|
|
|
|
//
|
2017-07-20 13:40:34 -07:00
|
|
|
// Official repository: https://github.com/boostorg/beast
|
|
|
|
|
//
|
2017-05-08 12:41:45 -07:00
|
|
|
|
|
|
|
|
// Test that header file is self-contained.
|
2017-07-20 13:40:34 -07:00
|
|
|
#include <boost/beast/http/buffer_body.hpp>
|
2019-10-04 06:01:49 -07:00
|
|
|
|
|
|
|
|
#include <boost/beast/core/flat_buffer.hpp>
|
|
|
|
|
#include <boost/beast/core/ostream.hpp>
|
|
|
|
|
#include <boost/beast/http/parser.hpp>
|
|
|
|
|
#include <boost/beast/http/read.hpp>
|
|
|
|
|
|
|
|
|
|
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
|
|
|
|
#include <boost/beast/_experimental/test/stream.hpp>
|
|
|
|
|
|
|
|
|
|
namespace boost {
|
|
|
|
|
namespace beast {
|
|
|
|
|
namespace http {
|
|
|
|
|
|
|
|
|
|
class buffer_body_test : public beast::unit_test::suite
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
void
|
2019-10-04 18:48:09 -07:00
|
|
|
testIssue1717()
|
2019-10-04 06:01:49 -07:00
|
|
|
{
|
|
|
|
|
net::io_context ioc;
|
|
|
|
|
test::stream ts{ioc};
|
|
|
|
|
ostream(ts.buffer()) <<
|
|
|
|
|
"HTTP/1.1 200 OK\r\n"
|
|
|
|
|
"Content-Length:3\r\n"
|
|
|
|
|
"\r\n"
|
|
|
|
|
"1.0";
|
|
|
|
|
error_code ec;
|
|
|
|
|
flat_buffer fb;
|
|
|
|
|
response_parser<buffer_body> p;
|
|
|
|
|
char buf[256];
|
|
|
|
|
p.get().body().data = buf;
|
|
|
|
|
p.get().body().size = sizeof(buf);
|
|
|
|
|
read_header(ts, fb, p, ec);
|
|
|
|
|
auto const bytes_transferred =
|
|
|
|
|
read(ts, fb, p, ec);
|
2020-01-24 11:28:24 +01:00
|
|
|
boost::ignore_unused(bytes_transferred);
|
2019-10-04 06:01:49 -07:00
|
|
|
BEAST_EXPECTS(! ec, ec.message());
|
|
|
|
|
|
|
|
|
|
// VFALCO What should the read algorithms return?
|
|
|
|
|
//BEAST_EXPECT(bytes_transferred == 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
run() override
|
|
|
|
|
{
|
|
|
|
|
testIssue1717();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BEAST_DEFINE_TESTSUITE(beast,http,buffer_body);
|
|
|
|
|
|
|
|
|
|
} // http
|
|
|
|
|
} // beast
|
|
|
|
|
} // boost
|