Skip to content

Commit

Permalink
Add HTTP proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeeg committed Aug 18, 2017
1 parent cbd756e commit cabd9df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG-MASTER.rst
Original file line number Diff line number Diff line change
@@ -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

4 changes: 4 additions & 0 deletions bravado/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions bravado/requests_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit cabd9df

Please sign in to comment.