Skip to content

Commit 564cafa

Browse files
author
Rudolfs Bundulis
committed
Updated header parser test case, removed duplicate status code
1 parent ceb1eb2 commit 564cafa

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

boost/network/protocol/http/impl/response.ipp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ namespace boost { namespace network { namespace http {
5353
temporary_redirect = 307,
5454
bad_request = 400,
5555
unauthorized = 401,
56-
forbidden = 403,
5756
payment_required = 402,
5857
forbidden = 403,
5958
not_found = 404,

libs/network/test/http/server_header_parser_test.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <boost/network/protocol/http/server.hpp>
88
#include <boost/config/warning_disable.hpp>
99
#include <boost/test/unit_test.hpp>
10+
#define BOOST_LOCALE_NO_LIB
11+
#include <boost/locale/encoding.hpp>
1012
#include <string>
1113
#include <iostream>
1214

@@ -26,17 +28,20 @@ namespace fusion = boost::fusion;
2628
using namespace boost::network::http;
2729

2830
BOOST_AUTO_TEST_CASE(async_connection_parse_headers) {
29-
request_header_narrow utf8_header = { "X-Utf8-Test-Header", "R\uc5abdolfs" };
31+
std::wstring utf16_test_name = L"R\u016bdolfs";
32+
request_header_narrow utf8_header = { "X-Utf8-Test-Header", boost::locale::conv::utf_to_utf<char>(utf16_test_name) };
3033
std::string valid_http_request;
3134
valid_http_request.append(utf8_header.name).append(": ").append(utf8_header.value).append("\r\n\r\n");
3235
std::vector<request_header_narrow> headers;
3336
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)
37+
std::vector<request_header_narrow>::iterator header_iterator = headers.begin();
38+
for(; header_iterator != headers.end(); ++ header_iterator)
3539
{
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-
}
40+
if (header_iterator->name == utf8_header.name && header_iterator->value == utf8_header.value)
41+
break;
42+
}
43+
std::wstring utf16_test_name_from_header = boost::locale::conv::utf_to_utf<wchar_t>(header_iterator->value);
44+
BOOST_CHECK(header_iterator != headers.end());
45+
BOOST_CHECK(utf16_test_name_from_header == utf16_test_name);
46+
std::cout << "utf8 header parsed, name: " << header_iterator->name << ", value: " << header_iterator->value;
47+
}

0 commit comments

Comments
 (0)