From cabd9dfcf32a814bd0fa4562d9e361ac28c0e547 Mon Sep 17 00:00:00 2001 From: Matthias Deeg Date: Fri, 18 Aug 2017 12:06:12 +0200 Subject: [PATCH] Add HTTP proxy support --- CHANGELOG-MASTER.rst | 4 +--- bravado/client.py | 4 ++++ bravado/requests_client.py | 9 +++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG-MASTER.rst b/CHANGELOG-MASTER.rst index f463782a..47ce576e 100644 --- a/CHANGELOG-MASTER.rst +++ b/CHANGELOG-MASTER.rst @@ -1,7 +1,5 @@ Changelog-Master ================ -*This file will contain the Changelog of the master branch.* - -*The content will be used to build the Changelog of the new bravado release.* +- Add HTTP proxy support for requests client via Bravado config diff --git a/bravado/client.py b/bravado/client.py index f93830fd..422087f4 100644 --- a/bravado/client.py +++ b/bravado/client.py @@ -141,6 +141,10 @@ def from_spec(cls, spec_dict, origin_url=None, http_client=None, # Apply bravado config defaults config = dict(CONFIG_DEFAULTS, **(config or {})) + # Apply bravado proxy settings + if 'proxies' in config: + http_client.updateProxies(config['proxies']) + swagger_spec = Spec.from_dict( spec_dict, origin_url, http_client, config) return cls(swagger_spec) diff --git a/bravado/requests_client.py b/bravado/requests_client.py index 56e8744d..6de588f1 100644 --- a/bravado/requests_client.py +++ b/bravado/requests_client.py @@ -123,6 +123,15 @@ def separate_params(request_params): return sanitized_params, misc_options + def updateProxies(self, proxies): + """ + :param proxies: proxies for Requests session + :type proxies: dict + + :returns None + """ + self.session.proxies.update(proxies) + def request(self, request_params, operation=None, response_callbacks=None, also_return_response=False): """