Skip to content

Commit a926ad4

Browse files
committed
Merge remote-tracking branch 'maxim-ky/master' into issue-161
2 parents 1bdbb5f + 2f1dee8 commit a926ad4

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

include/network/protocol/http/message/header.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace network {
2424
namespace http {
2525

2626
struct request_header {
27+
typedef std::string string_type;
2728
std::string name, value;
2829
};
2930

@@ -33,6 +34,7 @@ inline void swap(request_header & l, request_header & r) {
3334
}
3435

3536
struct response_header {
37+
typedef std::string string_type;
3638
std::string name, value;
3739
};
3840

include/network/uri/accessors.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ struct key_value_sequence
3232
{
3333
query = pair >> *((boost::spirit::qi::lit(';') | '&') >> pair);
3434
pair = key >> -('=' >> value);
35-
key = boost::spirit::qi::char_("a-zA-Z_") >> *boost::spirit::qi::char_("a-zA-Z_0-9/%");
36-
value = +boost::spirit::qi::char_("a-zA-Z_0-9/%");
35+
key = boost::spirit::qi::char_("a-zA-Z_") >> *boost::spirit::qi::char_("-+.~a-zA-Z_0-9/%");
36+
value = *boost::spirit::qi::char_("-+.~a-zA-Z_0-9/%");
3737
}
3838

3939
boost::spirit::qi::rule<uri::const_iterator, Map()> query;

include/network/uri/decode.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ OutputIterator decode(const InputIterator &in_begin,
7474
*out++ = 0x10 * v0 + v1;
7575
}
7676
else
77+
if (*it == '+')
78+
{
79+
*out++ = ' ';
80+
++ it;
81+
}
82+
else
7783
{
7884
*out++ = *it++;
7985
}

libs/network/test/uri/uri_test.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,17 @@ BOOST_AUTO_TEST_CASE(uri_unordered_set_test) {
694694
BOOST_REQUIRE(!uri_set.empty());
695695
BOOST_CHECK_EQUAL((*uri_set.begin()), network::uri("http://www.example.com/"));
696696
}
697+
698+
BOOST_AUTO_TEST_CASE(issue_161_test) {
699+
network::uri instance("http://www.example.com/path?param1=-&param2=some+plus+encoded+text&param3=~");
700+
BOOST_REQUIRE(network::valid(instance));
701+
702+
std::map<std::string, std::string> queries;
703+
network::query_map(instance, queries);
704+
BOOST_REQUIRE_EQUAL(queries.size(), std::size_t(3));
705+
BOOST_CHECK_EQUAL(queries["param1"], "-");
706+
BOOST_CHECK_EQUAL(queries["param2"], "some+plus+encoded+text");
707+
BOOST_CHECK_EQUAL(queries["param3"], "~");
708+
BOOST_CHECK_EQUAL(network::decoded(queries["param2"]), "some plus encoded text");
709+
}
710+

0 commit comments

Comments
 (0)