playframework/playframework — pull request #1910 by reid-spencer (2013-10-25 09:51:34+00:00)
Title: Make FormUrlEncoded Data Preserve Parameter Order. Fixes #1814

This should resolve the problem with Play! providing form parameters in an order that is not the same as what is in the request. It shows no regressions, has two additional tests that both pass, and my application continues to function with this change. :) Hopefully it causes no damage.

NOTE: The interface for FormUrlEncoded data has changed from Map to ListMap. They are compatible but clients who declared the result type may have to change their code. Not sure how much of a big deal that is for Play.

I get a nice introduction to the source code with this work. :)

Here is a summary of the changes I made in this commit.
* Write play.utils.OrderPreserving.groupBy to abstractly do groupBy while preserving order
* Created a separate module because there might be a need for other OrderPreserving things later.
* Utilize OrderPreserving.groupBy in FormUrlEncodedParser.scala so that it can return ListMap instead of Map
* Adjust ContentTypes, Fakes, and JavaParsers to use ListMap instead of Map for FormUrlEncoded bodies
* Write new test case for validating FormFieldOrder being received correctly out of the pipeline
* Extend test case for FormUrlEncodedParser to ensure it maintains parameter order.