drogonframework/drogon

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

Open

#2 489 ouverte le 10 avr. 2026

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)C++ (1 014 forks)batch import
good first issue

Métriques du dépôt

Stars
 (10 462 stars)
Métriques de merge PR
 (Merge moyen 2j 2h) (7 PRs mergées en 30 j)

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

Guide contributeur