lua-http icon indicating copy to clipboard operation
lua-http copied to clipboard

http/request: Add :set_form_data method

Open daurnimator opened this issue 9 years ago • 7 comments

This adds a convenience method for turning a request into a urlencoded form data POST request

daurnimator avatar May 04 '16 13:05 daurnimator

Coverage Status

Coverage decreased (-0.07%) to 86.267% when pulling ad28aa3ae24f8c571570640d7d915d633405913a on request.set_form_data into 929ba0c6cd9b06b4bf137598ba121dffc6a33f3e on master.

coveralls avatar May 04 '16 13:05 coveralls

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

daurnimator avatar May 04 '16 13:05 daurnimator

Coverage Status

Coverage increased (+0.02%) to 86.356% when pulling c8b2c21e1007e5307a14fa0620634c5f43c80914 on request.set_form_data into 929ba0c6cd9b06b4bf137598ba121dffc6a33f3e on master.

coveralls avatar May 04 '16 13:05 coveralls

I think you need to replace %20 with +.

daurnimator avatar May 26 '16 15:05 daurnimator

If this gets merged we also need decoding: you can't use query_args as it doesn't decode + to space. Cc @leafo

daurnimator avatar Oct 20 '16 06:10 daurnimator

Coverage Status

Coverage increased (+0.01%) to 86.233% when pulling 903e59c3bd5e4b0315dea747e49800c33cd022a6 on request.set_form_data into 8b7f4ba5dd0b2f8eb0e0766260981407596ea5b2 on master.

coveralls avatar Nov 15 '16 00:11 coveralls

Coverage Status

Coverage increased (+0.01%) to 88.048% when pulling 23840c45227c309fadcda73326ba9717c727ebeb on request.set_form_data into 95b6ec8d17c2d0408e628917cb89364792b64206 on master.

coveralls avatar Jan 09 '17 05:01 coveralls