libwww-perl / WWW-Mechanize

Handy web browsing in a Perl object
https://metacpan.org/pod/WWW::Mechanize
Other
68 stars 53 forks source link

->post_ok won't pass headers #222

Closed spazm closed 7 years ago

spazm commented 7 years ago

XenoTerr...@gmail.com reported on Mar 21, 2013

What steps will reproduce the problem?

use strict;
use warnings;
use Test::More;
use Test::WWW::Mechanize;

my $client  = Test::WWW::Mechanize->new;
my $url     = 'http://localhost/search';
my $headers = {'Content-Type' => 'application/x-www-form-urlencoded', Accept => 'application/json'};
my $data    = 'query=server-management&limit=1';

$client->post_ok( $url, { %$headers, Content => $data });
note $client->content;

done_testing;

What is the expected output? What do you see instead?
Expected
{"params":["query","limit"],"query":"server-management","Accept":"application/json","limit":"1"}

Instead
 {"params":["Accept","Content-Type","Content"],"query":"","Accept":"","limit":""}

What version of the product are you using? On what operating system?
1.72 Linux/Windows both

Please provide any additional information below.

the problem is at

https://metacpan.org/source/PETDANCE/Test-WWW-Mechanize-1.44/Mechanize.pm#L236

LWP::Useragent->post expects an array (or url + hash) not a url + hashref. removing the \ from %opts fixes the problem

Details

Imported from Google Code issue 245 via archive

oalders commented 7 years ago

Closing as this is not in the correct repo.