Hi,

Just a suggestion based on my recent struggle using Mojo::UserAgent to post 
some data. There are web sites that count on specific POST parameter order. 
All browsers send application/x-www-form-urlencoded data in tree order 
<http://www.w3.org/TR/html51/infrastructure.html#tree-order>, preserving a 
specific order of parameters as defined in DOM.

Just using
$tx = $ua->post($url => form => { b => 'param_1',  a => 'param_2' } );

will generate a request like:
 a=param_2&b=param_1

because the form generator sorts the keys of the hash. There is no simply 
way to generate a request like
 b=param_1&a=param_2
except building the Mojo::Parameters and Transactor manually.

May be you could just add the option to do:
$tx = $ua->post($url => form => [ b => 'param_1',  a => 'param_2' ] );

using an array reference instead of a hash one.

I am just a Mojo newbie, but I would dare to suggest :-) that replacing 
line 175 in Mojo::UserAgent::Transactor
my $p = Mojo::Parameters->new(map { $_ => $form->{$_} } sort keys %$form);

with something like:
my $p;
if ( ref $form eq 'HASH' ) { 
    $p = Mojo::Parameters->new(map { $_ => $form->{$_} } sort keys %$form);
} else {
    $p = Mojo::Parameters->new(@$form);
}

would do the trick.


Thank you.


-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to