3
3
from requests import Request , Session
4
4
5
5
from twilio .compat import urlparse
6
- from twilio .http import HttpClient , get_cert_file
6
+ from twilio .http import HttpClient
7
7
from twilio .http .response import Response
8
8
from twilio .jwt .validation import ClientValidationJwt
9
9
15
15
class ValidationClient (HttpClient ):
16
16
__SIGNED_HEADERS = ['authorization' , 'host' ]
17
17
18
- def __init__ (self , account_sid , api_key_sid , credential_sid , private_key ):
18
+ def __init__ (self , account_sid , api_key_sid , credential_sid , private_key , pool_connections = True ):
19
19
"""
20
20
Build a ValidationClient which signs requests with private_key and allows Twilio to
21
21
validate request has not been tampered with.
@@ -30,6 +30,7 @@ def __init__(self, account_sid, api_key_sid, credential_sid, private_key):
30
30
self .credential_sid = credential_sid
31
31
self .api_key_sid = api_key_sid
32
32
self .private_key = private_key
33
+ self .session = Session () if pool_connections else None
33
34
34
35
def request (self , method , url , params = None , data = None , headers = None , auth = None , timeout = None ,
35
36
allow_redirects = False ):
@@ -49,9 +50,7 @@ def request(self, method, url, params=None, data=None, headers=None, auth=None,
49
50
:return: An http response
50
51
:rtype: A :class:`Response <twilio.rest.http.response.Response>` object
51
52
"""
52
- session = Session ()
53
- session .verify = get_cert_file ()
54
-
53
+ session = self .session or Session ()
55
54
request = Request (method .upper (), url , params = params , data = data , headers = headers , auth = auth )
56
55
prepared_request = session .prepare_request (request )
57
56
0 commit comments