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:
Vinnie Falco
2017-07-20 08:12:13 -07:00
parent 8035dac88c
commit 1eb673dd7d
5 changed files with 385 additions and 11 deletions
+49
View File
@@ -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));