Skip to content

Commit

Permalink
feat: json content type (#737)
Browse files Browse the repository at this point in the history
* feat: add application/json support for client

* feat: add application/json support for client

* feat: add application/json support for client

* feat: add application/json support for client

* feat: add application/json support for client
  • Loading branch information
manisha1997 authored Dec 1, 2023
1 parent 33363be commit 3509e61
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions twilio/http/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -79,12 +78,14 @@ def request(
"method": method.upper(),
"url": url,
"params": params,
"data": data,
"headers": headers,
"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
Expand Down

0 comments on commit 3509e61

Please sign in to comment.