Skip to content

Commit b78fb25

Browse files
committed
Merge commit 'origin/fork-integration'
2 parents f90ab05 + 25d9366 commit b78fb25

File tree

7 files changed

+42
-52
lines changed

7 files changed

+42
-52
lines changed

RATIONALE renamed to RATIONALE.txt

File renamed without changes.

boost/network/uri/detail/constants.hpp

Whitespace-only changes.

boost/network/uri/detail/parse_uri.hpp

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef BOOST_NETWORK_URL_DETAIL_PARSE_URL_HPP_
22
#define BOOST_NETWORK_URL_DETAIL_PARSE_URL_HPP_
33

4-
// Copyright 2009 Dean Michael Berris.
4+
// Copyright 2009 Dean Michael Berris, Jeroen Habraken.
55
// Distributed under the Boost Software License, Version 1.0.
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
@@ -20,30 +20,23 @@ namespace boost { namespace network { namespace uri {
2020

2121
template <class Range, class Tag>
2222
inline bool parse_uri(Range & range, uri_parts<Tag> & parts) {
23-
using spirit::qi::parse;
24-
using spirit::qi::lexeme;
25-
using spirit::ascii::char_;
26-
using spirit::ascii::cntrl;
27-
using spirit::ascii::alnum;
28-
using spirit::ascii::space;
29-
using namespace spirit::qi::labels;
30-
using fusion::tie;
23+
namespace qi = boost::spirit::qi;
3124

3225
typedef typename range_iterator<Range>::type iterator;
3326
typedef typename string<Tag>::type string_type;
3427

3528
iterator start_ = begin(range);
3629
iterator end_ = end(range);
3730
fusion::tuple<string_type&,string_type&> result =
38-
tie(parts.scheme,parts.scheme_specific_part);
31+
fusion::tie(parts.scheme,parts.scheme_specific_part);
3932

40-
bool ok = parse(
33+
bool ok = qi::parse(
4134
start_, end_,
4235
(
43-
+((alnum|char_("+.-")) - ':')
36+
(qi::alpha > *(qi::alnum | qi::char_("+.-")))
4437
>> ':'
4538
>>
46-
+(char_ - (cntrl|space))
39+
+(qi::char_ - (qi::cntrl | qi::space))
4740
),
4841
result
4942
);

boost/network/uri/http/detail/parse_specific.hpp

+29-32
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#ifndef BOOST_NETWORK_URL_HTTP_DETAIL_PARSE_SPECIFIC_HPP_
22
#define BOOST_NETWORK_URL_HTTP_DETAIL_PARSE_SPECIFIC_HPP_
33

4-
// Copyright 2009 Dean Michael Berris.
4+
// Copyright 2009 Dean Michael Berris, Jeroen Habraken.
55
// Distributed under the Boost Software License, Version 1.0.
66
// (See accompanying file LICENSE_1_0.txt of copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9+
#include <boost/algorithm/string/predicate.hpp>
910
#include <boost/network/uri/http/detail/uri_parts.hpp>
1011
#include <boost/network/uri/detail/parse_uri.hpp>
11-
#include <boost/network/uri/detail/constants.hpp>
1212
#include <boost/network/traits/string.hpp>
1313

1414
namespace boost { namespace network { namespace uri {
@@ -51,27 +51,18 @@ namespace boost { namespace network { namespace uri {
5151
uri_parts<tags::http> & parts
5252
)
5353
{
54-
// Require that parts.scheme is either http or https
55-
if (parts.scheme.size() < 4)
56-
return false;
57-
if (parts.scheme.substr(0, 4) != "http")
54+
namespace qi = spirit::qi;
55+
56+
// Require that parts.scheme is either http or https, case insensitive
57+
if (parts.scheme.size() < 4 or parts.scheme.size() > 5)
5858
return false;
59-
if (parts.scheme.size() == 5) {
60-
if (parts.scheme[4] != 's')
59+
if (parts.scheme.size() == 4) {
60+
if (not boost::iequals(parts.scheme.substr(0, 4), "http"))
6161
return false;
62-
} else if (parts.scheme.size() > 5)
63-
return false;
64-
65-
using spirit::qi::parse;
66-
using spirit::qi::lit;
67-
using spirit::ascii::char_;
68-
using spirit::ascii::space;
69-
using spirit::ascii::alnum;
70-
using spirit::ascii::punct;
71-
using spirit::qi::lexeme;
72-
using spirit::qi::uint_;
73-
using spirit::qi::digit;
74-
using spirit::qi::rule;
62+
} else { // size is 5
63+
if (not boost::iequals(parts.scheme.substr(0, 5), "https"))
64+
return false;
65+
}
7566

7667
typedef string<tags::http>::type string_type;
7768
typedef range_iterator<string_type>::type iterator;
@@ -81,7 +72,7 @@ namespace boost { namespace network { namespace uri {
8172
fusion::tuple<
8273
optional<string_type> &,
8374
string_type &,
84-
optional<uint32_t> &,
75+
optional<uint16_t> &,
8576
optional<string_type> &,
8677
optional<string_type> &,
8778
optional<string_type> &
@@ -95,20 +86,26 @@ namespace boost { namespace network { namespace uri {
9586
parts.fragment
9687
);
9788

89+
qi::rule<iterator, string_type::value_type()> gen_delims = qi::char_(":/?#[]@");
90+
qi::rule<iterator, string_type::value_type()> sub_delims = qi::char_("!$&'()*+,;=");
91+
92+
qi::rule<iterator, string_type::value_type()> reserved = gen_delims | sub_delims;
93+
qi::rule<iterator, string_type::value_type()> unreserved = qi::alnum | qi::char_("-._~");
94+
qi::rule<iterator, string_type()> pct_encoded = qi::char_("%") > qi::repeat(2)[qi::xdigit];
95+
96+
qi::rule<iterator, string_type()> pchar = qi::raw[unreserved | pct_encoded | sub_delims | qi::char_(":@")];
97+
9898
hostname<tags::http>::parser<iterator> hostname;
99-
bool ok = parse(
99+
bool ok = qi::parse(
100100
start_, end_,
101101
(
102-
lit("//")
103-
>> -lexeme[
104-
*((alnum|punct) - '@')
105-
>> '@'
106-
]
102+
qi::lit("//")
103+
>> -qi::lexeme[qi::raw[*(unreserved | pct_encoded | sub_delims | qi::char_(":"))] >> '@']
107104
>> hostname
108-
>> -lexeme[':' >> uint_]
109-
>> -lexeme['/' >> *((alnum|punct) - '?')]
110-
>> -lexeme['?' >> *((alnum|punct) - '#')]
111-
>> -lexeme['#' >> *(alnum|punct)]
105+
>> -qi::lexeme[':' >> qi::ushort_]
106+
>> -qi::lexeme['/' > qi::raw[*pchar >> *('/' > *pchar)]]
107+
>> -qi::lexeme['?' >> qi::raw[*(pchar | qi::char_("/?"))]]
108+
>> -qi::lexeme['#' >> qi::raw[*(pchar | qi::char_("/?"))]]
112109
),
113110
result
114111
);

boost/network/uri/http/detail/uri_parts.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef BOOST_NETWORK_URL_HTTP_DETAIL_URL_PARTS_HPP_
22
#define BOOST_NETWORK_URL_HTTP_DETAIL_URL_PARTS_HPP_
33

4-
// Copyright 2009 Dean Michael Berris.
4+
// Copyright 2009 Dean Michael Berris, Jeroen Habraken.
55
// Distributed under the Boost Software License, Version 1.0.
66
// (See accompanying file LICENSE_1_0.txt of copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
@@ -19,7 +19,7 @@ namespace boost { namespace network { namespace uri {
1919
string_type scheme_specific_part;
2020
optional<string_type> user_info;
2121
string_type host;
22-
optional<uint32_t> port;
22+
optional<uint16_t> port;
2323
optional<string_type> path;
2424
optional<string_type> query;
2525
optional<string_type> fragment;

boost/network/uri/http/uri.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef BOOST_NETWORK_URL_HTTP_URL_HPP_
22
#define BOOST_NETWORK_URL_HTTP_URL_HPP_
33

4-
// Copyright 2009 Dean Michael Berris.
4+
// Copyright 2009 Dean Michael Berris, Jeroen Habraken.
55
// Distributed under the Boost Software License, Version 1.0.
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
@@ -30,7 +30,7 @@ namespace boost { namespace network { namespace uri {
3030
return parts_.host;
3131
}
3232

33-
uint32_t port() const {
33+
uint16_t port() const {
3434
return parts_.port ? *parts_.port :
3535
(parts_.scheme == "https" ? 443u : 80u);
3636
}
@@ -60,7 +60,7 @@ namespace boost { namespace network { namespace uri {
6060
}
6161

6262
inline
63-
uint32_t
63+
uint16_t
6464
port(basic_uri<tags::http> const & uri) {
6565
return uri.port();
6666
}

boost/network/uri/http/uri_concept.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef BOOST_NETWORK_URL_HTTP_URL_CONCEPT_HPP_
22
#define BOOST_NETWORK_URL_HTTP_URL_CONCEPT_HPP_
33

4-
// Copyright 2009 Dean Michael Berris.
4+
// Copyright 2009 Dean Michael Berris, Jeroen Habraken.
55
// Distributed under the Boost Software License, Version 1.0.
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
@@ -19,7 +19,7 @@ namespace boost { namespace network { namespace uri {
1919
{
2020
string_type user_info_ = user_info(uri);
2121
string_type host_ = host(uri);
22-
uint32_t port_ = port(uri);
22+
uint16_t port_ = port(uri);
2323
port_ = 0u;
2424
string_type path_ = path(uri);
2525
string_type query_ = query(uri);

0 commit comments

Comments
 (0)