RussellLuo / caddy-ext

Various Caddy v2 extensions (a.k.a. modules).
MIT License
98 stars 20 forks source link

Please Add Support for application/x-www-form-urlencoded Media Type in request_body_var Plugin #24

Open qingmuhy744 opened 2 months ago

qingmuhy744 commented 2 months ago

I am currently using the request_body_var plugin with Caddy to handle requests and extract variables from the request body. However, I've encountered an issue where the plugin does not support requests with the application/x-www-form-urlencoded content type. This is a common content type used in many web forms and handling this correctly is crucial for many server-side applications.

Error Details: When attempting to retrieve a variable from a request body with the content type application/x-www-form-urlencoded, the plugin fails to initialize the querier and logs the following error:

{"level":"error","ts":1726639454.9856362,"logger":"http.handlers.request_body_var","msg":"failed to new querier","key":"Username","error":"unsupported Media Type: \"application/x-www-form-urlencoded\""}
This indicates that the current implementation does not support parsing application/x-www-form-urlencoded content types.

This indicates that the current implementation does not support parsing application/x-www-form-urlencoded content types.

Expected Behavior: The plugin should be able to handle application/x-www-form-urlencoded content type by parsing the request body and allowing extraction of specified keys, similar to how it handles JSON and XML.

RussellLuo commented 1 month ago

@qingmuhy744 This should be relatively easy to implement, PRs are welcome :)