Skip to content

Commit 2a9e5fe

Browse files
committed
if data is dict send it as form data.
1 parent 02feba3 commit 2a9e5fe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

adafruit_requests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ def request(method, url, data=None, json=None, headers=None, stream=False, timeo
212212
data = json_module.dumps(json)
213213
sock.send(b"Content-Type: application/json\r\n")
214214
if data:
215+
if type(data) is dict:
216+
sock.send(b"Content-Type: application/x-www-form-urlencoded\r\n")
217+
_post_data = ""
218+
for k in data:
219+
_post_data = "{}&{}={}".format(_post_data, k, data[k])
220+
data = _post_data[1:]
215221
sock.send(b"Content-Length: %d\r\n" % len(data))
216222
sock.send(b"\r\n")
217223
if data:

0 commit comments

Comments
 (0)