From 833dee4415facf6e2f0580057fcb7a6adfdd8dac Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Mon, 27 Nov 2023 17:24:29 +0530 Subject: [PATCH 1/5] feat: add application/json support for client --- twilio/http/http_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index bfc38feaf..a3505ca8a 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -79,12 +79,16 @@ def request( "method": method.upper(), "url": url, "params": params, - "data": data, "headers": headers, "auth": auth, "hooks": self.request_hooks, } + if headers is not None and 'Content-Type' in headers.keys() and headers['Content-Type'] == 'application/json': + kwargs['json'] = data + else: + kwargs['data'] = data + self.log_request(kwargs) self._test_only_last_response = None From 54a1c087c17356d08c2586c89ccde1f04e8ab202 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Mon, 27 Nov 2023 18:06:34 +0530 Subject: [PATCH 2/5] feat: add application/json support for client --- twilio/http/http_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index a3505ca8a..17481194f 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -84,7 +84,7 @@ def request( "hooks": self.request_hooks, } - if headers is not None and 'Content-Type' in headers.keys() and headers['Content-Type'] == 'application/json': + if headers and headers.get('Content-Type') == 'application/json': kwargs['json'] = data else: kwargs['data'] = data From d0d40444733d176d16023ec48116592b34bb5284 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Mon, 27 Nov 2023 21:59:01 +0530 Subject: [PATCH 3/5] feat: add application/json support for client --- twilio/http/http_client.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index 17481194f..81c13626c 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -27,11 +27,10 @@ def __init__( ): """ Constructor for the TwilioHttpClient - :param pool_connections :param request_hooks :param timeout: Timeout for the requests. - Timeout should never be zero (0) or less. + Timeout should never be zero (0) or less :param logger :param proxy: Http proxy for the requests session :param max_retries: Maximum number of retries each request should attempt @@ -65,10 +64,10 @@ def request( :param headers: HTTP Headers to send with the request :param auth: Basic Auth arguments :param timeout: Socket/Read timeout for the request - :param allow_redirects: Whether or not to allow redirects + :param allow_redirects: Whether to allow redirects See the requests documentation for explanation of all these parameters - :return: An http response + :return: An HTTP response """ if timeout is None: timeout = self.timeout From b5fafca454fe3768fa879195112c4eccd9495d82 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Tue, 28 Nov 2023 11:33:25 +0530 Subject: [PATCH 4/5] feat: add application/json support for client --- twilio/http/http_client.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index 81c13626c..0403a6c82 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -82,12 +82,10 @@ def request( "auth": auth, "hooks": self.request_hooks, } - if headers and headers.get('Content-Type') == 'application/json': kwargs['json'] = data else: kwargs['data'] = data - self.log_request(kwargs) self._test_only_last_response = None From e4d056171030a6fe539b42ff2e594e3758bb6b17 Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Tue, 28 Nov 2023 11:44:16 +0530 Subject: [PATCH 5/5] feat: add application/json support for client --- twilio/http/http_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/twilio/http/http_client.py b/twilio/http/http_client.py index 0403a6c82..7a1715ad4 100644 --- a/twilio/http/http_client.py +++ b/twilio/http/http_client.py @@ -82,10 +82,10 @@ def request( "auth": auth, "hooks": self.request_hooks, } - if headers and headers.get('Content-Type') == 'application/json': - kwargs['json'] = data + if headers and headers.get("Content-Type") == "application/json": + kwargs["json"] = data else: - kwargs['data'] = data + kwargs["data"] = data self.log_request(kwargs) self._test_only_last_response = None