Support multipart/form-data
gbrlsnchs opened this issue · 3 comments
gbrlsnchs commented
Does this plugin only accept JSON requests? This was not clear in docs, and I also wasn't able to do form-data requests.
nicwest commented
Good question!
In theory yes, if curl supports it then the plugin should support it.
It would look something like this:
POST http://httpbin.org/post HTTP/1.1
Host: httpbin.org
Content-Type: multipart/form-data;boundary="boundary"
Content-Length: 174
--boundary
Content-Disposition: form-data; name="field1"
value1
--boundary
Content-Disposition: form-data; name="field2"; filename="example.txt"
value2
--boundary--
HTTP/1.1 200 OK
Date: Mon, 24 May 2021 11:51:12 GMT
Content-Type: application/json
Content-Length: 463
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
{
"args": {},
"data": "",
"files": {
"field2": "value2"
},
"form": {
"field1": "value1"
},
"headers": {
"Accept": "*/*",
"Content-Length": "174",
"Content-Type": "multipart/form-data;boundary=boundary",
"Host": "httpbin.org",
"User-Agent": "curl/7.68.0",
"X-Amzn-Trace-Id": "Root=1-60ab9330-6da5fc59153f7d211345873c"
},
"json": null,
"origin": "79.173.133.167",
"url": "http://httpbin.org/post"
}
Some boundary defining helper methods might be helpful.