1
+ // Copyright 2010 Dean Michael Berris.
2
+ // Distributed under the Boost Software License, Version 1.0.
3
+ // (See accompanying file LICENSE_1_0.txt or copy at
4
+ // http://www.boost.org/LICENSE_1_0.txt)
5
+
6
+ #define BOOST_TEST_MODULE HTTP Server Header Parser Test
7
+ #include < boost/network/protocol/http/server.hpp>
8
+ #include < boost/config/warning_disable.hpp>
9
+ #include < boost/test/unit_test.hpp>
10
+ #include < string>
11
+ #include < iostream>
12
+
13
+ /* * Synopsis
14
+ *
15
+ * Test for Utf8 support in the asynchronous connection header parser
16
+ * --------------------------------------------
17
+ *
18
+ * This test checks for Utf8 support in the header parser
19
+ * for asynchronous connection
20
+ *
21
+ */
22
+
23
+ namespace tags = boost::network::tags;
24
+ namespace logic = boost::logic;
25
+ namespace fusion = boost::fusion;
26
+ using namespace boost ::network::http;
27
+
28
+ BOOST_AUTO_TEST_CASE (async_connection_parse_headers) {
29
+ request_header_narrow utf8_header = { " X-Utf8-Test-Header" , " R\uc5ab dolfs" };
30
+ std::string valid_http_request;
31
+ valid_http_request.append (utf8_header.name ).append (" : " ).append (utf8_header.value ).append (" \r\n\r\n " );
32
+ std::vector<request_header_narrow> headers;
33
+ parse_headers (valid_http_request, headers);
34
+ std::vector<request_header_narrow>::iterator utf8_header_iterator = std::find_if (headers.begin (), headers.end (), [&utf8_header, &utf8_header_iterator](request_header_narrow& header)
35
+ {
36
+ if (header.name == utf8_header.name && header.value == utf8_header.value )
37
+ return true ;
38
+ return false ;
39
+ });
40
+ BOOST_CHECK (utf8_header_iterator != headers.end ());
41
+ std::cout << " utf8 header parsed, name: " << utf8_header_iterator->name << " , value: " << utf8_header_iterator->value << std::endl;
42
+ }
0 commit comments