Skip to content

Commit 64d7419

Browse files
committed
Merge pull request #349 from deanberris/0.11-devel
Add support for always_verify_peer as an option to HTTP Clients
2 parents 8c15fa8 + 8d9538f commit 64d7419

17 files changed

+594
-542
lines changed

.ycm_extra_conf.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright 2013 Google, Inc.
2+
# Copyright 2013 Dean Michael Berris <dberris@google.com>
3+
# Distributed under the Boost Software License, Version 1.0.
4+
# (See accompanying file LICENSE_1_0.txt or copy at
5+
# http://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
# Project-wide configuration for YouCompleteMe Vim plugin.
8+
#
9+
# Based off of Valloric's .ycm_conf_extra.py for YouCompleteMe:
10+
# https://github.com/Valloric/YouCompleteMe/blob/master/cpp/ycm/.ycm_extra_conf.py
11+
#
12+
13+
import os
14+
import ycm_core
15+
16+
flags = [
17+
'-Wall',
18+
'-Wextra',
19+
'-Werror',
20+
'-std=c++03',
21+
'-isystem',
22+
'.',
23+
'-isystem',
24+
'/usr/include',
25+
'-isystem',
26+
'/usr/include/c++/4.6',
27+
'-isystem',
28+
'/usr/include/clang/3.0/include',
29+
'-I',
30+
os.environ['BOOST_ROOT'],
31+
# Always enable debugging for the project when building for semantic
32+
# completion.
33+
'-DBOOST_NETWORK_DEBUG',
34+
]
35+
36+
def DirectoryOfThisScript():
37+
return os.path.dirname(os.path.abspath(__file__))
38+
39+
40+
def MakeRelativePathsInFlagsAbsolute(flags, working_directory):
41+
if not working_directory:
42+
return list(flags)
43+
new_flags = []
44+
make_next_absolute = False
45+
path_flags = ['-isystem', '-I', '-iquote', '--sysroot=']
46+
for flag in flags:
47+
new_flag = flag
48+
if make_next_absolute:
49+
make_next_absolute = False
50+
if not flag.startswith('/'):
51+
new_flag = os.path.join(working_directory, flag)
52+
53+
for path_flag in path_flags:
54+
if flag == path_flag:
55+
make_next_absolute = True
56+
break
57+
if flag.startswith(path_flag):
58+
path = flag[len(path_flag):]
59+
new_flag = path_flag + os.path.join(working_directory, path)
60+
break
61+
62+
if new_flag:
63+
new_flags.append(new_flag)
64+
return new_flags
65+
66+
67+
def FlagsForFile(filename):
68+
relative_to = DirectoryOfThisScript()
69+
final_flags = MakeRelativePathsInFlagsAbsolute(flags, relative_to)
70+
return {'flags': final_flags, 'do_cache': True }

boost/network/protocol/http/client/async_impl.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ struct async_client
3636

3737
typedef function<bool(string_type&)> body_generator_function_type;
3838

39-
async_client(bool cache_resolved,
40-
bool follow_redirect,
39+
async_client(bool cache_resolved, bool follow_redirect,
40+
bool always_verify_peer,
4141
boost::shared_ptr<boost::asio::io_service> service,
4242
optional<string_type> const& certificate_filename,
4343
optional<string_type> const& verify_path)
@@ -49,7 +49,8 @@ struct async_client
4949
resolver_(service_),
5050
sentinel_(new boost::asio::io_service::work(service_)),
5151
certificate_filename_(certificate_filename),
52-
verify_path_(verify_path) {
52+
verify_path_(verify_path),
53+
always_verify_peer_(always_verify_peer) {
5354
connection_base::resolver_strand_.reset(
5455
new boost::asio::io_service::strand(service_));
5556
lifetime_thread_.reset(new boost::thread(
@@ -65,16 +66,15 @@ struct async_client
6566
}
6667

6768
basic_response<Tag> const request_skeleton(
68-
basic_request<Tag> const& request_,
69-
string_type const& method,
70-
bool get_body,
71-
body_callback_function_type callback,
69+
basic_request<Tag> const& request_, string_type const& method,
70+
bool get_body, body_callback_function_type callback,
7271
body_generator_function_type generator) {
7372
typename connection_base::connection_ptr connection_;
7473
connection_ = connection_base::get_connection(
75-
resolver_, request_, certificate_filename_, verify_path_);
76-
return connection_->send_request(
77-
method, request_, get_body, callback, generator);
74+
resolver_, request_, always_verify_peer_, certificate_filename_,
75+
verify_path_);
76+
return connection_->send_request(method, request_, get_body, callback,
77+
generator);
7878
}
7979

8080
boost::shared_ptr<boost::asio::io_service> service_ptr;
@@ -83,6 +83,7 @@ struct async_client
8383
boost::shared_ptr<boost::asio::io_service::work> sentinel_;
8484
boost::shared_ptr<boost::thread> lifetime_thread_;
8585
optional<string_type> certificate_filename_, verify_path_;
86+
bool always_verify_peer_;
8687
};
8788
} // namespace impl
8889
} // namespace http

boost/network/protocol/http/client/connection/async_base.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace boost { namespace network { namespace http { namespace impl {
3737
resolve_function resolve,
3838
resolver_type & resolver,
3939
bool follow_redirect,
40+
bool always_verify_peer,
4041
bool https,
4142
optional<string_type> certificate_filename=optional<string_type>(),
4243
optional<string_type> const & verify_path=optional<string_type>()) {
@@ -52,6 +53,7 @@ namespace boost { namespace network { namespace http { namespace impl {
5253
delegate_factory_type::new_connection_delegate(
5354
resolver.get_io_service(),
5455
https,
56+
always_verify_peer,
5557
certificate_filename,
5658
verify_path)));
5759
BOOST_ASSERT(temp.get() != 0);

0 commit comments

Comments
 (0)