forked from boostorg/beast
Add read, async_read for message_headers:
fix #172, fix #173 This provides overloads of read and async_read to allow reading message_headers objects.
This commit is contained in:
@@ -244,6 +244,52 @@ public:
|
||||
failMatrix<false>(res[i], do_yield);
|
||||
}
|
||||
|
||||
void testReadHeaders(yield_context do_yield)
|
||||
{
|
||||
static std::size_t constexpr limit = 100;
|
||||
std::size_t n;
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
test::fail_stream<test::string_stream> fs{n, ios_,
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: localhost\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 5\r\n"
|
||||
"\r\n"
|
||||
};
|
||||
request_headers m;
|
||||
try
|
||||
{
|
||||
streambuf sb;
|
||||
read(fs, sb, m);
|
||||
break;
|
||||
}
|
||||
catch(std::exception const&)
|
||||
{
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
test::fail_stream<test::string_stream> fs(n, ios_,
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"Host: localhost\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"\r\n"
|
||||
);
|
||||
request_headers m;
|
||||
error_code ec;
|
||||
streambuf sb;
|
||||
async_read(fs, sb, m, do_yield[ec]);
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void testRead(yield_context do_yield)
|
||||
{
|
||||
static std::size_t constexpr limit = 100;
|
||||
@@ -335,6 +381,9 @@ public:
|
||||
yield_to(std::bind(&read_test::testFailures,
|
||||
this, std::placeholders::_1));
|
||||
|
||||
yield_to(std::bind(&read_test::testReadHeaders,
|
||||
this, std::placeholders::_1));
|
||||
|
||||
yield_to(std::bind(&read_test::testRead,
|
||||
this, std::placeholders::_1));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user