Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: json content type #737

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading