Skip to content
Open
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
9 changes: 8 additions & 1 deletion languages/python/templates/rest.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ class RESTClientObject:
url,
data=request_body,
headers=headers,
timeout=_request_timeout,
)
elif content_type == 'application/x-www-form-urlencoded':
r = self.session.request(
method,
url,
params=post_params,
headers=headers,
timeout=_request_timeout,
)
elif content_type == 'multipart/form-data':
# must del headers['Content-Type'], or the correct
Expand All @@ -124,6 +126,7 @@ class RESTClientObject:
url,
files=post_params,
headers=headers,
timeout=_request_timeout,
)
# Pass a `string` parameter directly in the body to support
# other content types than JSON when `body` argument is
Expand All @@ -134,14 +137,17 @@ class RESTClientObject:
url,
data=body,
headers=headers,
timeout=_request_timeout,
)
elif headers['Content-Type'].startswith('text/') and isinstance(body, bool):
request_body = "true" if body else "false"
r = self.session.request(
method,
url,
data=request_body,
headers=headers)
headers=headers,
timeout=_request_timeout,
)
else:
# Cannot generate the request from given parameters
msg = """Cannot prepare a request message for provided
Expand All @@ -155,6 +161,7 @@ class RESTClientObject:
url,
params={},
headers=headers,
timeout=_request_timeout,
)
except requests.exceptions.SSLError as e:
msg = "\n".join([type(e).__name__, str(e)])
Expand Down