lua-http
lua-http copied to clipboard
http/request: Add :set_form_data method
This adds a convenience method for turning a request into a urlencoded form data POST request
Coverage decreased (-0.07%) to 86.267% when pulling ad28aa3ae24f8c571570640d7d915d633405913a on request.set_form_data into 929ba0c6cd9b06b4bf137598ba121dffc6a33f3e on master.
Why does form data deserve it's own function when there are so many other formats to choose from? e.g. json, xml, etc. Obviously we don't want to depend on json/xml libraries, so we can't add helpers for all common formats.
See also #7
The main rationale seems to be that people expect there to be a :set_form_data-like function in a HTTP library.
- luasocket's http has a code-path for it
- prosody has a code-path for it
- curl has a commad line option for it
Coverage increased (+0.02%) to 86.356% when pulling c8b2c21e1007e5307a14fa0620634c5f43c80914 on request.set_form_data into 929ba0c6cd9b06b4bf137598ba121dffc6a33f3e on master.
I think you need to replace %20 with +.
If this gets merged we also need decoding: you can't use query_args as it doesn't decode + to space. Cc @leafo
Coverage increased (+0.01%) to 86.233% when pulling 903e59c3bd5e4b0315dea747e49800c33cd022a6 on request.set_form_data into 8b7f4ba5dd0b2f8eb0e0766260981407596ea5b2 on master.