You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The specification for HTTP POST is that it has a "message body". HTML forms sticks encoded key/values representing form inputs into that message body when submitted. However, this means that currently requests.post can't accept JSON or XML message bodies, which could make it hard to use with some APIs. Therefore, I propose the following:
"""inside of requests.post method"""ifisinstance(data, dict):
# process as existing code now handles POSTelifisinstance(data, str) orisinstance(data, unicode):
# Stick into message body# Do encoding if that is what the spec demands (I'm not sure)else:
# raise InvalidRequestDataFormat"""Example of implementation"""importjsonimportrequestspost_dict= {"hello":"world"}
r=request.post(form_url, post_dict)
post_json=json.dumps(post_dict)
r=request.post(json_url, post_json)
The text was updated successfully, but these errors were encountered:
The specification for HTTP POST is that it has a "message body". HTML forms sticks encoded key/values representing form inputs into that message body when submitted. However, this means that currently requests.post can't accept JSON or XML message bodies, which could make it hard to use with some APIs. Therefore, I propose the following:
The text was updated successfully, but these errors were encountered: