HTTP.jl icon indicating copy to clipboard operation
HTTP.jl copied to clipboard

Support decoding of `application/x-www-form-urlencoded` forms

Open nguiard opened this issue 2 years ago • 0 comments

Hi! Thanks a lot for this library!

As HTTP.jl supports queryparams to decode parameters of a query string, I am surprised there's no facility to decode forms encoded in application/x-www-form-urlencoded. Especially as this is the default encoding for web forms.

Important to note is that the encoding is actually slightly different from query strings in URLs, so you can't just use queryparams as is on the body. The key difference is that a space character is encoded as a + in x-www-form-urlencoded while it is encoded as a %20 in URIs (https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding).

While one can easily write a homegrown function in their project to take care of it, this body encoding is so ubiquitous that I suggest HTTP.jl should offer a standard function to decode it, and also an example in the documentation. Not doing so can also be error-prone for people not familiar with web forms: looking around a bit, they might think they can just use queryparams on the body, not realizing this is incorrect.

If you're fine with that, I can prepare a PR to add this functionality as well as a nice example of using it :)

nguiard avatar Oct 10 '23 15:10 nguiard