Skip to content

Backport fix for #163 into 0.11.0 #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions boost/network/uri/accessors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct key_value_sequence
{
query = pair >> *((spirit::qi::lit(';') | '&') >> pair);
pair = key >> -('=' >> value);
key = spirit::qi::char_("a-zA-Z_") >> *spirit::qi::char_("a-zA-Z_0-9/%");
value = +spirit::qi::char_("a-zA-Z_0-9/%");
key = spirit::qi::char_("a-zA-Z_") >> *spirit::qi::char_("-+.~a-zA-Z_0-9/%");
value = +spirit::qi::char_("-+.~a-zA-Z_0-9/%");
}

spirit::qi::rule<uri::const_iterator, Map()> query;
Expand Down
106 changes: 45 additions & 61 deletions boost/network/uri/decode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,21 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)


#ifndef __BOOST_NETWORK_URI_DECODE_INC__
# define __BOOST_NETWORK_URI_DECODE_INC__


# include <boost/iterator/iterator_traits.hpp>
# include <boost/range/begin.hpp>
# include <boost/range/end.hpp>
# include <cassert>
#define __BOOST_NETWORK_URI_DECODE_INC__

#include <boost/iterator/iterator_traits.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <cassert>

namespace boost {
namespace network {
namespace uri {
namespace detail {
template <
typename CharT
>
CharT letter_to_hex(CharT in)
{
switch (in)
{
template <typename CharT>
CharT letter_to_hex(CharT in) {
switch (in) {
case '0':
case '1':
case '2':
Expand All @@ -35,74 +28,65 @@ CharT letter_to_hex(CharT in)
case '7':
case '8':
case '9':
return in - '0';
return in - '0';
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
return in + 10 - 'a';
return in + 10 - 'a';
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
return in + 10 - 'A';
}
return CharT();
return in + 10 - 'A';
}
return CharT();
}
} // namespace detail
} // namespace detail

template <
class InputIterator,
class OutputIterator
>
template <class InputIterator, class OutputIterator>
OutputIterator decode(const InputIterator &in_begin,
const InputIterator &in_end,
const OutputIterator &out_begin) {
typedef typename boost::iterator_value<InputIterator>::type value_type;
typedef typename boost::iterator_value<InputIterator>::type value_type;

InputIterator it = in_begin;
OutputIterator out = out_begin;
while (it != in_end) {
if (*it == '%')
{
++it;
value_type v0 = detail::letter_to_hex(*it);
++it;
value_type v1 = detail::letter_to_hex(*it);
++it;
*out++ = 0x10 * v0 + v1;
}
else
{
*out++ = *it++;
}
InputIterator it = in_begin;
OutputIterator out = out_begin;
while (it != in_end) {
if (*it == '%') {
++it;
value_type v0 = detail::letter_to_hex(*it);
++it;
value_type v1 = detail::letter_to_hex(*it);
++it;
*out++ = 0x10 * v0 + v1;
} else if (*it == '+') {
*out++ = ' ';
++it;
} else {
*out++ = *it++;
}
return out;
}
return out;
}

template <
class SinglePassRange,
class OutputIterator
>
inline
OutputIterator decode(const SinglePassRange &range,
const OutputIterator &out) {
return decode(boost::begin(range), boost::end(range), out);
template <class SinglePassRange, class OutputIterator>
inline OutputIterator decode(const SinglePassRange &range,
const OutputIterator &out) {
return decode(boost::begin(range), boost::end(range), out);
}

inline
std::string decoded(const std::string &input) {
std::string decoded;
decode(input, std::back_inserter(decoded));
return decoded;
inline std::string decoded(const std::string &input) {
std::string decoded;
decode(input, std::back_inserter(decoded));
return decoded;
}
} // namespace uri
} // namespace network
} // namespace boost

} // namespace uri
} // namespace network
} // namespace boost

#endif // __BOOST_NETWORK_URI_DECODE_INC__
#endif // __BOOST_NETWORK_URI_DECODE_INC__
78 changes: 44 additions & 34 deletions libs/network/doc/reference/http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,40 +168,50 @@ initialization.
Constructor taking a ``client_options<Tag>`` object. The following table
shows the options you can set on a ``client_options<Tag>`` instance.

+---------------------+----------------------------+--------------------------+
| Parameter Name | Type | Description |
+=====================+============================+==========================+
| follow_redirects | ``bool`` | Boolean to specify |
| | | whether the client |
| | | should follow HTTP |
| | | redirects. Default is |
| | | ``false``. |
+---------------------+----------------------------+--------------------------+
| cache_resolved | ``bool`` | Boolean to specify |
| | | whether the client |
| | | should cache resolved |
| | | endpoints. The default |
| | | is ``false``. |
+---------------------+----------------------------+--------------------------+
| io_service | ``shared_ptr<io_service>`` | Shared pointer to a |
| | | Boost.Asio |
| | | ``io_service``. |
+---------------------+----------------------------+--------------------------+
| openssl_certificate | ``string`` | The filename of the |
| | | certificate to load for |
| | | the SSL connection for |
| | | verification. |
+---------------------+----------------------------+--------------------------+
| openssl_verify_path | ``string`` | The directory from |
| | | which the certificate |
| | | authority files are |
| | | located. |
+---------------------+----------------------------+--------------------------+
| always_verify_peer | ``bool`` | Boolean to specify |
| | | whether the client |
| | | should always verify |
| | | peers in SSL connections |
+---------------------+----------------------------+--------------------------+
+--------------------------+----------------------------+--------------------------+
| Parameter Name | Type | Description |
+==========================+============================+==========================+
| follow_redirects | ``bool`` | Boolean to specify |
| | | whether the client |
| | | should follow HTTP |
| | | redirects. Default is |
| | | ``false``. |
+--------------------------+----------------------------+--------------------------+
| cache_resolved | ``bool`` | Boolean to specify |
| | | whether the client |
| | | should cache resolved |
| | | endpoints. The default |
| | | is ``false``. |
+--------------------------+----------------------------+--------------------------+
| io_service | ``shared_ptr<io_service>`` | Shared pointer to a |
| | | Boost.Asio |
| | | ``io_service``. |
+--------------------------+----------------------------+--------------------------+
| openssl_certificate | ``string`` | The filename of the |
| | | certificate to load for |
| | | the SSL connection for |
| | | verification. |
+--------------------------+----------------------------+--------------------------+
| openssl_verify_path | ``string`` | The directory from |
| | | which the certificate |
| | | authority files are |
| | | located. |
+--------------------------+----------------------------+--------------------------+
| always_verify_peer | ``bool`` | Boolean to specify |
| | | whether the client |
| | | should always verify |
| | | peers in SSL connections |
+--------------------------+----------------------------+--------------------------+
| openssl_certificate_file | ``string`` | Filename of the |
| | | certificate to use for |
| | | client-side SSL session |
| | | establishment. |
+--------------------------+----------------------------+--------------------------+
| openssl_private_key_file | ``string`` | Filename of the |
| | | private key to use for |
| | | client-side SSL session |
| | | establishment. |
+--------------------------+----------------------------+--------------------------+


To use the above supported named parameters, you'll have code that looks like
Expand Down
4 changes: 4 additions & 0 deletions libs/network/doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ v0.11.0
``cpp-netlib-utils_base64_test`` still fails in this platform. (`#287`_)
* Provide a client option to always validate peers for HTTPS requests made by
the client. (`#349`_)
* Back-port fix for `#163`_ for improved URI parsing.
* Added support for client-side certificates and private keys (`#361`_).

.. _`#129`: https://github.com/cpp-netlib/cpp-netlib/issues/129
.. _`#163`: https://github.com/cpp-netlib/cpp-netlib/issues/163
.. _`#245`: https://github.com/cpp-netlib/cpp-netlib/issues/245
.. _`#277`: https://github.com/cpp-netlib/cpp-netlib/issues/277
.. _`#279`: https://github.com/cpp-netlib/cpp-netlib/issues/279
Expand All @@ -40,6 +43,7 @@ v0.11.0
.. _`#349`: https://github.com/cpp-netlib/cpp-netlib/issues/349
.. _`#69`: https://github.com/cpp-netlib/cpp-netlib/issues/69
.. _`#86`: https://github.com/cpp-netlib/cpp-netlib/issues/86
.. _`#361`: https://github.com/cpp-netlib/cpp-netlib/pull/361

:mod:`cpp-netlib` 0.10
----------------------
Expand Down
Loading