drogon icon indicating copy to clipboard operation
drogon copied to clipboard

getParameters

Open jiangwenming27488 opened this issue 1 year ago • 3 comments

when using req->getParameters(),I can not get the paramter of same key,for example,url is:/api/list?key="hello"&key="world" when I call req->getParameters().equal_range("key") it only display the result value key="world" and ignore the fist value "hello"

jiangwenming27488 avatar Jun 20 '23 03:06 jiangwenming27488

As the parsing of query parameters is not defined in any RFC, the behavior is to be defined by the framework. I would say that in this case the described behavior is also what is to be expected.

There are some frameworks like PHP which support serialization of parameters with same names, but this is by no means a standard.

I think it makes sense to stay here somewhat with the RFC which only talks about unique parameters in the context of forms, and also apply it to query parameters.

Do you have any specific use cases where you rely on this implicit query parameter parsing behavior besides the “Hello, world!” example? Maybe there is another elegant solution.

rbugajewski avatar Jun 20 '23 10:06 rbugajewski

req->getQuery() , get the full query string, and parse whatever you want.

sinnren avatar Jun 28 '23 10:06 sinnren

+1 from me. It'd be very useful if Drogon could properly handle arrays of parameters. It's not part of the RFC but it is industry standard for many years.

cjserio avatar Sep 06 '23 13:09 cjserio