Skip to content

Commit c5bfff6

Browse files
committed
Add arguments check_cert and use_session to ArangoClient
1 parent 0ca6478 commit c5bfff6

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

arango/client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class ArangoClient(object):
3030
:type http_client: arango.http_clients.base.BaseHTTPClient
3131
:param enable_logging: log all API requests
3232
:type enable_logging: bool
33+
:param check_cert: verify SSL certificate when making HTTP requests
34+
:type check_cert: bool
35+
:param use_session: use session when making HTTP requests
36+
:type use_session: bool
3337
"""
3438

3539
def __init__(self,
@@ -40,14 +44,19 @@ def __init__(self,
4044
password='',
4145
verify=False,
4246
http_client=None,
43-
enable_logging=True):
47+
enable_logging=True,
48+
check_cert=True,
49+
use_session=True):
4450

4551
self._protocol = protocol
4652
self._host = host
4753
self._port = port
4854
self._username = username
4955
self._password = password
50-
self._http_client = http_client or DefaultHTTPClient()
56+
self._http_client = DefaultHTTPClient(
57+
use_session=use_session,
58+
check_cert=check_cert
59+
) if http_client is None else http_client
5160
self._logging = enable_logging
5261
self._conn = Connection(
5362
protocol=self._protocol,

arango/http_clients/default.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ class DefaultHTTPClient(BaseHTTPClient):
1212
.. _requests: http://docs.python-requests.org/en/master/
1313
"""
1414

15-
def __init__(self, use_session=True):
15+
def __init__(self, use_session=True, check_cert=True):
1616
"""Initialize the session."""
1717
if use_session:
1818
self._session = requests.Session()
1919
else:
2020
self._session = requests
21+
self._check_cert = check_cert
2122

2223
def head(self, url, params=None, headers=None, auth=None):
2324
"""Execute an HTTP **HEAD** method.
@@ -37,7 +38,8 @@ def head(self, url, params=None, headers=None, auth=None):
3738
url=url,
3839
params=params,
3940
headers=headers,
40-
auth=auth
41+
auth=auth,
42+
verify=self._check_cert
4143
)
4244
return Response(
4345
url=url,
@@ -66,7 +68,8 @@ def get(self, url, params=None, headers=None, auth=None):
6668
url=url,
6769
params=params,
6870
headers=headers,
69-
auth=auth
71+
auth=auth,
72+
verify=self._check_cert
7073
)
7174
return Response(
7275
url=url,
@@ -98,7 +101,8 @@ def put(self, url, data, params=None, headers=None, auth=None):
98101
data=data,
99102
params=params,
100103
headers=headers,
101-
auth=auth
104+
auth=auth,
105+
verify=self._check_cert
102106
)
103107
return Response(
104108
url=url,
@@ -130,7 +134,8 @@ def post(self, url, data, params=None, headers=None, auth=None):
130134
data=data,
131135
params=params,
132136
headers=headers,
133-
auth=auth
137+
auth=auth,
138+
verify=self._check_cert
134139
)
135140
return Response(
136141
url=url,
@@ -162,7 +167,8 @@ def patch(self, url, data, params=None, headers=None, auth=None):
162167
data=data,
163168
params=params,
164169
headers=headers,
165-
auth=auth
170+
auth=auth,
171+
verify=self._check_cert
166172
)
167173
return Response(
168174
url=url,
@@ -194,7 +200,8 @@ def delete(self, url, data=None, params=None, headers=None, auth=None):
194200
data=data,
195201
params=params,
196202
headers=headers,
197-
auth=auth
203+
auth=auth,
204+
verify=self._check_cert
198205
)
199206
return Response(
200207
url=url,

arango/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '3.2.2'
1+
VERSION = '3.3.0'

0 commit comments

Comments
 (0)