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

Update client.py to allow ssl context to be passed in #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions aiohttp_xmlrpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@


class ServerProxy(object):
__slots__ = 'client', 'url', 'loop', 'headers', 'encoding'
__slots__ = 'client', 'url', 'ssl', 'loop', 'headers', 'encoding'

USER_AGENT = u'aiohttp XML-RPC client (Python: {0}, version: {1})'.format(__pyversion__, __version__)

def __init__(self, url, client=None, loop=None, headers=None, encoding=None, **kwargs):
def __init__(self, url, ssl_context=None, client=None, loop=None, headers=None, encoding=None, **kwargs):
self.headers = MultiDict(headers or {})

self.headers.setdefault('Content-Type', 'text/xml')
Expand All @@ -27,6 +27,7 @@ def __init__(self, url, client=None, loop=None, headers=None, encoding=None, **k
self.encoding = encoding

self.url = str(url)
self.ssl = ssl_context
self.loop = loop or asyncio.get_event_loop()
self.client = client or aiohttp.client.ClientSession(loop=self.loop, **kwargs)

Expand Down Expand Up @@ -89,6 +90,7 @@ def _parse_response(body, method_name):
def __remote_call(self, method_name, *args, **kwargs):
response = yield from self.client.post(
str(self.url),
ssl_context = self.ssl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssl_context is deprecated

data=etree.tostring(
self._make_request(method_name, *args, **kwargs),
xml_declaration=True,
Expand Down