33from requests import Request , Session
44
55from twilio .compat import urlparse
6- from twilio .http import HttpClient , get_cert_file
6+ from twilio .http import HttpClient
77from twilio .http .response import Response
88from twilio .jwt .validation import ClientValidationJwt
99
1515class ValidationClient (HttpClient ):
1616 __SIGNED_HEADERS = ['authorization' , 'host' ]
1717
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 ):
1919 """
2020 Build a ValidationClient which signs requests with private_key and allows Twilio to
2121 validate request has not been tampered with.
@@ -30,6 +30,7 @@ def __init__(self, account_sid, api_key_sid, credential_sid, private_key):
3030 self .credential_sid = credential_sid
3131 self .api_key_sid = api_key_sid
3232 self .private_key = private_key
33+ self .session = Session () if pool_connections else None
3334
3435 def request (self , method , url , params = None , data = None , headers = None , auth = None , timeout = None ,
3536 allow_redirects = False ):
@@ -49,9 +50,7 @@ def request(self, method, url, params=None, data=None, headers=None, auth=None,
4950 :return: An http response
5051 :rtype: A :class:`Response <twilio.rest.http.response.Response>` object
5152 """
52- session = Session ()
53- session .verify = get_cert_file ()
54-
53+ session = self .session or Session ()
5554 request = Request (method .upper (), url , params = params , data = data , headers = headers , auth = auth )
5655 prepared_request = session .prepare_request (request )
5756
0 commit comments