drogonframework/drogon

Ability to add query parameters using `HttpRequest::setParameter` when the method is `POST`

Open

#2489 opened on Apr 10, 2026

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C++ (10,462 stars) (1,014 forks)batch import
good first issue

Description

Is your feature request related to a problem? Please describe. When I needed to add a query parameter to a HttpRequest, I used setParameter("key", "value"), which worked as expected when the method was GET, but when the method is POST and the content type is multipart/form-data, setParameter adds the parameter to the body. I also tried to add the query parameter manually via setPath("/endpoint?key=" + value), and since value has a space in it, I ended up using setPath("/endpoint?key=" + utils::urlEncodeComponent(value) (just like in the HttpRequest implementation) but for some reason that did not work As I was writing this I found out that setPath() automatically encodes the path (maybe add something like "(see setPathEncode())" to the setPath doc comment) and it worked, but I'd prefer setQueryParameter as you could keep it consistent across requests, independent of the HTTP method

Describe the solution you'd like I'd like to have either an overload for setParameter to explicitly specify query/body, or a pair of setQueryParameter/setBodyParameter functions where the former always adds to the query and the latter only works when the content type is multipart/form-data or application/x-www-form-urlencoded and will throw otherwise

Contributor guide