forked from boostorg/beast
Boost prep
This commit is contained in:
+60
-56
@@ -4,28 +4,31 @@
|
||||
// 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)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <beast/http/write.hpp>
|
||||
#include <boost/beast/http/write.hpp>
|
||||
|
||||
#include <beast/http/buffer_body.hpp>
|
||||
#include <beast/http/empty_body.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/test/fail_stream.hpp>
|
||||
#include <beast/test/pipe_stream.hpp>
|
||||
#include <beast/test/string_istream.hpp>
|
||||
#include <beast/test/string_ostream.hpp>
|
||||
#include <beast/test/yield_to.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/http/buffer_body.hpp>
|
||||
#include <boost/beast/http/empty_body.hpp>
|
||||
#include <boost/beast/http/fields.hpp>
|
||||
#include <boost/beast/http/message.hpp>
|
||||
#include <boost/beast/http/read.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/test/fail_stream.hpp>
|
||||
#include <boost/beast/test/pipe_stream.hpp>
|
||||
#include <boost/beast/test/string_istream.hpp>
|
||||
#include <boost/beast/test/string_ostream.hpp>
|
||||
#include <boost/beast/test/yield_to.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -300,8 +303,8 @@ public:
|
||||
error_code ec;
|
||||
test::string_ostream ss{ios_};
|
||||
async_write(ss, m, do_yield[ec]);
|
||||
if(BEAST_EXPECTS(ec == error::end_of_stream, ec.message()))
|
||||
BEAST_EXPECT(ss.str ==
|
||||
if(BOOST_BEAST_EXPECTS(ec == error::end_of_stream, ec.message()))
|
||||
BOOST_BEAST_EXPECT(ss.str ==
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Server: test\r\n"
|
||||
"Content-Length: 5\r\n"
|
||||
@@ -318,8 +321,8 @@ public:
|
||||
error_code ec;
|
||||
test::string_ostream ss(ios_);
|
||||
async_write(ss, m, do_yield[ec]);
|
||||
if(BEAST_EXPECTS(! ec, ec.message()))
|
||||
BEAST_EXPECT(ss.str ==
|
||||
if(BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
BOOST_BEAST_EXPECT(ss.str ==
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Server: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -349,7 +352,7 @@ public:
|
||||
try
|
||||
{
|
||||
write(fs, m);
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
@@ -364,7 +367,7 @@ public:
|
||||
{
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -379,7 +382,7 @@ public:
|
||||
write(fs, m, ec);
|
||||
if(ec == error::end_of_stream)
|
||||
{
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -394,7 +397,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -409,7 +412,7 @@ public:
|
||||
async_write(fs, m, do_yield[ec]);
|
||||
if(ec == error::end_of_stream)
|
||||
{
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -424,7 +427,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -440,7 +443,7 @@ public:
|
||||
write(fs, m, ec);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
@@ -451,7 +454,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -467,7 +470,7 @@ public:
|
||||
async_write(fs, m, do_yield[ec]);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
@@ -478,7 +481,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -493,7 +496,7 @@ public:
|
||||
m.set(field::user_agent, "test");
|
||||
m.body = "*";
|
||||
m.prepare_payload();
|
||||
BEAST_EXPECT(str(m) ==
|
||||
BOOST_BEAST_EXPECT(str(m) ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 1\r\n"
|
||||
@@ -513,8 +516,8 @@ public:
|
||||
test::string_ostream ss(ios_);
|
||||
error_code ec;
|
||||
write(ss, m, ec);
|
||||
BEAST_EXPECT(ec == error::end_of_stream);
|
||||
BEAST_EXPECT(ss.str ==
|
||||
BOOST_BEAST_EXPECT(ec == error::end_of_stream);
|
||||
BOOST_BEAST_EXPECT(ss.str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"\r\n"
|
||||
@@ -530,7 +533,7 @@ public:
|
||||
m.set(field::user_agent, "test");
|
||||
m.body = "*";
|
||||
m.prepare_payload();
|
||||
BEAST_EXPECT(str(m) ==
|
||||
BOOST_BEAST_EXPECT(str(m) ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 1\r\n"
|
||||
@@ -550,7 +553,7 @@ public:
|
||||
test::string_ostream ss(ios_);
|
||||
error_code ec;
|
||||
write(ss, m, ec);
|
||||
BEAST_EXPECT(ss.str ==
|
||||
BOOST_BEAST_EXPECT(ss.str ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -571,7 +574,7 @@ public:
|
||||
m.version = 11;
|
||||
m.set(field::user_agent, "test");
|
||||
m.body = "*";
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(m) ==
|
||||
BOOST_BEAST_EXPECT(boost::lexical_cast<std::string>(m) ==
|
||||
"GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n*");
|
||||
}
|
||||
|
||||
@@ -594,7 +597,7 @@ public:
|
||||
// after calling io_service::stop
|
||||
boost::asio::io_service ios;
|
||||
test::string_ostream os{ios};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
request<string_body> m;
|
||||
m.method(verb::get);
|
||||
m.version = 11;
|
||||
@@ -602,13 +605,13 @@ public:
|
||||
m.set("Content-Length", 5);
|
||||
m.body = "*****";
|
||||
async_write(os, m, handler{});
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
ios.stop();
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
ios.reset();
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
ios.run_one();
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
}
|
||||
{
|
||||
// Make sure uninvoked handlers are
|
||||
@@ -616,7 +619,7 @@ public:
|
||||
{
|
||||
boost::asio::io_service ios;
|
||||
test::string_ostream is{ios};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
request<string_body> m;
|
||||
m.method(verb::get);
|
||||
m.version = 11;
|
||||
@@ -624,9 +627,9 @@ public:
|
||||
m.set("Content-Length", 5);
|
||||
m.body = "*****";
|
||||
async_write(is, m, handler{});
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
}
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,7 +649,7 @@ public:
|
||||
write_some(stream, sr, ec);
|
||||
if(ec)
|
||||
return;
|
||||
BEAST_EXPECT(stream.nwrite <= 1);
|
||||
BOOST_BEAST_EXPECT(stream.nwrite <= 1);
|
||||
if(sr.is_done())
|
||||
break;
|
||||
}
|
||||
@@ -669,7 +672,7 @@ public:
|
||||
async_write_some(stream, sr, yield[ec]);
|
||||
if(ec)
|
||||
return;
|
||||
BEAST_EXPECT(stream.nwrite <= 1);
|
||||
BOOST_BEAST_EXPECT(stream.nwrite <= 1);
|
||||
if(sr.is_done())
|
||||
break;
|
||||
}
|
||||
@@ -699,8 +702,8 @@ public:
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
do_write(p.client, m, ec);
|
||||
BEAST_EXPECT(p.server.str() == result);
|
||||
BEAST_EXPECT(equal_body<false>(
|
||||
BOOST_BEAST_EXPECT(p.server.str() == result);
|
||||
BOOST_BEAST_EXPECT(equal_body<false>(
|
||||
p.server.str(), m.body.s));
|
||||
p.server.clear();
|
||||
}
|
||||
@@ -708,8 +711,8 @@ public:
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
do_async_write(p.client, m, ec, yield);
|
||||
BEAST_EXPECT(p.server.str() == result);
|
||||
BEAST_EXPECT(equal_body<false>(
|
||||
BOOST_BEAST_EXPECT(p.server.str() == result);
|
||||
BOOST_BEAST_EXPECT(equal_body<false>(
|
||||
p.server.str(), m.body.s));
|
||||
p.server.clear();
|
||||
}
|
||||
@@ -724,7 +727,7 @@ public:
|
||||
if(sr.is_header_done())
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(! m.body.read);
|
||||
BOOST_BEAST_EXPECT(! m.body.read);
|
||||
p.server.clear();
|
||||
}
|
||||
{
|
||||
@@ -738,7 +741,7 @@ public:
|
||||
if(sr.is_header_done())
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(! m.body.read);
|
||||
BOOST_BEAST_EXPECT(! m.body.read);
|
||||
p.server.clear();
|
||||
}
|
||||
}
|
||||
@@ -748,7 +751,7 @@ public:
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
do_write(p.client, m, ec);
|
||||
BEAST_EXPECT(equal_body<false>(
|
||||
BOOST_BEAST_EXPECT(equal_body<false>(
|
||||
p.server.str(), m.body.s));
|
||||
p.server.clear();
|
||||
}
|
||||
@@ -756,7 +759,7 @@ public:
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
do_async_write(p.client, m, ec, yield);
|
||||
BEAST_EXPECT(equal_body<false>(
|
||||
BOOST_BEAST_EXPECT(equal_body<false>(
|
||||
p.server.str(), m.body.s));
|
||||
p.server.clear();
|
||||
}
|
||||
@@ -772,7 +775,7 @@ public:
|
||||
if(sr.is_header_done())
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(! m.body.read);
|
||||
BOOST_BEAST_EXPECT(! m.body.read);
|
||||
p.server.clear();
|
||||
}
|
||||
{
|
||||
@@ -786,7 +789,7 @@ public:
|
||||
if(sr.is_header_done())
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(! m.body.read);
|
||||
BOOST_BEAST_EXPECT(! m.body.read);
|
||||
p.server.clear();
|
||||
}
|
||||
}
|
||||
@@ -832,7 +835,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(write,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(write,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
Reference in New Issue
Block a user