Skip to content
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

Add HTTP proxy support #309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 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