It turns out that Net::HTTP seems to always use UTF-8 as the default
encoding, even when Encoding.default_external is Encoding::IBM437 (as it
is on Windows/mingw).
Remove the old standalone implementation of Utils.encode_query_string in
favor of the unified version based on Utils.flatten_params.
This means that params in GET, POST x-www-form-urlencoded, and
POST multipart/form-data will all be handled in the same way (except for
escaping, since multipart/form-data is not escaped).
Begin the transition to unified HTTP parameter flattening by
reimplementing Payload::Base#flatten_params as Utils.flatten_params.
This new method uses a single recursive function rather than two
mutually recursive functions. It also establishes more unified handling
of URI escaping and nil or empty values.
Add a new method Utils.encode_query_string2 that is implemented in terms
of flatten_params. This will replace Utils.encode_query_string in the
next commit, but keep them both around in this commit for ease of
directly comparing their output to verify their equivalence.
Because of RestClient's use of Hashes to represent structured HTTP
parameters, there was previously no way to pass a structured ruby object
that contained the same key multiple times.
ParamsArray behaves similarly to Array, but enforces a little more
validation. It is intended to be used in place of a Hash in methods to
process HTTP parameters where duplicate keys are desired.
Switch the generation of HTTP GET params over to the new, more
featureful method in Utils, which handles Rack/Rails style nested
parameters. Also add a variety of tests for this functionality.