Parser concept, fixes:

A new concept Parser is introduced with routines to read from a stream
into the parser. This solves a problem with the old read interface where
messages must be default constructible and move assignable.

Parser fixes:

* Fix detect invalid reason-phrase octets
* Fix write_eof to set the 'complete' state on success
* Fix consider parse complete if eof received on empty body

WebSocket:

* Increase coverage
This commit is contained in:
Vinnie Falco
2016-04-30 10:29:39 -04:00
parent 8921da91b8
commit 2a8de0fd6b
28 changed files with 1536 additions and 701 deletions

View File

@@ -7,3 +7,38 @@
// Test that header file is self-contained.
#include <beast/http/streambuf_body.hpp>
#include <beast/core/to_string.hpp>
#include <beast/http/headers.hpp>
#include <beast/http/parser_v1.hpp>
#include <beast/http/read.hpp>
#include <beast/test/string_stream.hpp>
#include <beast/unit_test/suite.hpp>
namespace beast {
namespace http {
class streambuf_body_test : public beast::unit_test::suite
{
boost::asio::io_service ios_;
public:
void run() override
{
test::string_stream ss(ios_,
"HTTP/1.1 200 OK\r\n"
"Server: test\r\n"
"Content-Length: 3\r\n"
"\r\n"
"xyz");
parser_v1<false, streambuf_body, headers> p;
streambuf sb;
parse(ss, sb, p);
expect(to_string(p.get().body.data()) == "xyz");
}
};
BEAST_DEFINE_TESTSUITE(streambuf_body,http,beast);
} // http
} // beast