Skip to content

Add support for always_verify_peer as an option to HTTP Clients #349

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 2 commits into from
Dec 16, 2013
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
70 changes: 70 additions & 0 deletions .ycm_extra_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2013 Google, Inc.
# Copyright 2013 Dean Michael Berris <dberris@google.com>
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Project-wide configuration for YouCompleteMe Vim plugin.
#
# Based off of Valloric's .ycm_conf_extra.py for YouCompleteMe:
# https://github.com/Valloric/YouCompleteMe/blob/master/cpp/ycm/.ycm_extra_conf.py
#

import os
import ycm_core

flags = [
'-Wall',
'-Wextra',
'-Werror',
'-std=c++03',
'-isystem',
'.',
'-isystem',
'/usr/include',
'-isystem',
'/usr/include/c++/4.6',
'-isystem',
'/usr/include/clang/3.0/include',
'-I',
os.environ['BOOST_ROOT'],
# Always enable debugging for the project when building for semantic
# completion.
'-DBOOST_NETWORK_DEBUG',
]

def DirectoryOfThisScript():
return os.path.dirname(os.path.abspath(__file__))


def MakeRelativePathsInFlagsAbsolute(flags, working_directory):
if not working_directory:
return list(flags)
new_flags = []
make_next_absolute = False
path_flags = ['-isystem', '-I', '-iquote', '--sysroot=']
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith('/'):
new_flag = os.path.join(working_directory, flag)

for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith(path_flag):
path = flag[len(path_flag):]
new_flag = path_flag + os.path.join(working_directory, path)
break

if new_flag:
new_flags.append(new_flag)
return new_flags


def FlagsForFile(filename):
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute(flags, relative_to)
return {'flags': final_flags, 'do_cache': True }
21 changes: 11 additions & 10 deletions boost/network/protocol/http/client/async_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ struct async_client

typedef function<bool(string_type&)> body_generator_function_type;

async_client(bool cache_resolved,
bool follow_redirect,
async_client(bool cache_resolved, bool follow_redirect,
bool always_verify_peer,
boost::shared_ptr<boost::asio::io_service> service,
optional<string_type> const& certificate_filename,
optional<string_type> const& verify_path)
Expand All @@ -49,7 +49,8 @@ struct async_client
resolver_(service_),
sentinel_(new boost::asio::io_service::work(service_)),
certificate_filename_(certificate_filename),
verify_path_(verify_path) {
verify_path_(verify_path),
always_verify_peer_(always_verify_peer) {
connection_base::resolver_strand_.reset(
new boost::asio::io_service::strand(service_));
lifetime_thread_.reset(new boost::thread(
Expand All @@ -65,16 +66,15 @@ struct async_client
}

basic_response<Tag> const request_skeleton(
basic_request<Tag> const& request_,
string_type const& method,
bool get_body,
body_callback_function_type callback,
basic_request<Tag> const& request_, string_type const& method,
bool get_body, body_callback_function_type callback,
body_generator_function_type generator) {
typename connection_base::connection_ptr connection_;
connection_ = connection_base::get_connection(
resolver_, request_, certificate_filename_, verify_path_);
return connection_->send_request(
method, request_, get_body, callback, generator);
resolver_, request_, always_verify_peer_, certificate_filename_,
verify_path_);
return connection_->send_request(method, request_, get_body, callback,
generator);
}

boost::shared_ptr<boost::asio::io_service> service_ptr;
Expand All @@ -83,6 +83,7 @@ struct async_client
boost::shared_ptr<boost::asio::io_service::work> sentinel_;
boost::shared_ptr<boost::thread> lifetime_thread_;
optional<string_type> certificate_filename_, verify_path_;
bool always_verify_peer_;
};
} // namespace impl
} // namespace http
Expand Down
2 changes: 2 additions & 0 deletions boost/network/protocol/http/client/connection/async_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace boost { namespace network { namespace http { namespace impl {
resolve_function resolve,
resolver_type & resolver,
bool follow_redirect,
bool always_verify_peer,
bool https,
optional<string_type> certificate_filename=optional<string_type>(),
optional<string_type> const & verify_path=optional<string_type>()) {
Expand All @@ -52,6 +53,7 @@ namespace boost { namespace network { namespace http { namespace impl {
delegate_factory_type::new_connection_delegate(
resolver.get_io_service(),
https,
always_verify_peer,
certificate_filename,
verify_path)));
BOOST_ASSERT(temp.get() != 0);
Expand Down
Loading