]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // |
2 | // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | // | |
7 | ||
8 | // Test that header file is self-contained. | |
9 | #include <beast/http/streambuf_body.hpp> | |
10 | ||
11 | #include <beast/core/to_string.hpp> | |
12 | #include <beast/http/fields.hpp> | |
13 | #include <beast/http/message_parser.hpp> | |
14 | #include <beast/http/read.hpp> | |
15 | #include <beast/http/write.hpp> | |
16 | #include <beast/test/string_istream.hpp> | |
17 | #include <beast/unit_test/suite.hpp> | |
18 | #include <boost/lexical_cast.hpp> | |
19 | ||
20 | namespace beast { | |
21 | namespace http { | |
22 | ||
23 | class streambuf_body_test : public beast::unit_test::suite | |
24 | { | |
25 | boost::asio::io_service ios_; | |
26 | ||
27 | public: | |
28 | void run() override | |
29 | { | |
30 | std::string const s = | |
31 | "HTTP/1.1 200 OK\r\n" | |
32 | "Server: test\r\n" | |
33 | "Content-Length: 3\r\n" | |
34 | "\r\n" | |
35 | "xyz"; | |
36 | test::string_istream ss(ios_, s); | |
37 | message_parser<false, streambuf_body, fields> p; | |
38 | streambuf sb; | |
39 | read(ss, sb, p); | |
40 | auto const& m = p.get(); | |
41 | BEAST_EXPECT(to_string(m.body.data()) == "xyz"); | |
42 | BEAST_EXPECT(boost::lexical_cast<std::string>(m) == s); | |
43 | } | |
44 | }; | |
45 | ||
46 | BEAST_DEFINE_TESTSUITE(streambuf_body,http,beast); | |
47 | ||
48 | } // http | |
49 | } // beast |