]>
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/header_parser.hpp> | |
10 | ||
11 | #include <beast/core/flat_streambuf.hpp> | |
12 | #include <beast/http/read.hpp> | |
13 | #include <beast/unit_test/suite.hpp> | |
14 | #include <beast/test/string_istream.hpp> | |
15 | #include <beast/test/yield_to.hpp> | |
16 | ||
17 | namespace beast { | |
18 | namespace http { | |
19 | ||
20 | class header_parser_test | |
21 | : public beast::unit_test::suite | |
22 | , public test::enable_yield_to | |
23 | { | |
24 | public: | |
25 | void | |
26 | testParse() | |
27 | { | |
28 | { | |
29 | test::string_istream is{ios_, | |
30 | "GET / HTTP/1.1\r\n" | |
31 | "User-Agent: test\r\n" | |
32 | "\r\n" | |
33 | }; | |
34 | flat_streambuf db{1024}; | |
35 | header_parser<true, fields> p; | |
36 | read_some(is, db, p); | |
37 | BEAST_EXPECT(p.is_complete()); | |
38 | } | |
39 | { | |
40 | test::string_istream is{ios_, | |
41 | "POST / HTTP/1.1\r\n" | |
42 | "User-Agent: test\r\n" | |
43 | "Content-Length: 1\r\n" | |
44 | "\r\n" | |
45 | "*" | |
46 | }; | |
47 | flat_streambuf db{1024}; | |
48 | header_parser<true, fields> p; | |
49 | read_some(is, db, p); | |
50 | BEAST_EXPECT(! p.is_complete()); | |
51 | BEAST_EXPECT(p.state() == parse_state::body); | |
52 | } | |
53 | } | |
54 | ||
55 | void | |
56 | run() override | |
57 | { | |
58 | testParse(); | |
59 | } | |
60 | }; | |
61 | ||
62 | BEAST_DEFINE_TESTSUITE(header_parser,http,beast); | |
63 | ||
64 | } // http | |
65 | } // beast | |
66 |