Unify `queryMap` methods, fix diffent behaviour and edge cases by mkurz · Pull Request #13223 · playframework/playframework
...WORK IN PROGRESS...
I am not working on this right now, I am just pushing things I tried a couple of days ago.
No one complained yet and I think it's not so super important right now because some edge cases are really total edge cases.
Like said in that comment we use a different logic to create the query map and in some cases the methods behave slightly different. Of course it would be better if all methods use the same logic/method.
Test code for sample app to test locally
Java action:
public Result index(Http.Request request) { System.out.println(); System.out.println("one:" + request.queryString("one")); System.out.println("two:" + request.queryString("two")); System.out.println("three:" + request.queryString("three")); System.out.println("empty:" + request.queryString("")); return ok( "one:" + request.queryString("one") + "<br>" + "one?+" + request.queryString("one?+") + "<br>" + "two:" + request.queryString("two") + "<br>" + "two=:" + request.queryString("two=") + "<br>" + "three:" + request.queryString("three") + "<br>" + "empty:" + request.queryString("") + "<br>" + "empty_all:" + Arrays.stream(request.queryString().getOrDefault("", new String[]{"<empty>"})).collect(Collectors.joining(",")) ).as("text/html");
Equivalent Scala action:
def index() = Action { implicit request: Request[AnyContent] => println() println("one:" + request.getQueryString("one")) println("two:" + request.getQueryString("two")) println("three:" + request.getQueryString("three")) println("empty:" + request.getQueryString("")) Ok( "one:" + request.getQueryString("one") + "<br>" + "one?+:" + request.getQueryString("one?+") + "<br>" + "two:" + request.getQueryString("two") + "<br>" + "two=:" + request.getQueryString("two=") + "<br>" + "three:" + request.getQueryString("three") + "<br>" + "empty:" + request.getQueryString("") + "<br>" + "empty_all:" + request.queryString.get("").map(_.mkString(",")) ).as("text/html"); }
Testing with:
http://localhost:9000/?one=&two=a+b&
http://localhost:9000/?one&two=a+b&
http://localhost:9000/?one=&two=a+b&=
http://localhost:9000/?one&two=a+b
http://localhost:9000/?one?%2B=&two%3D