Skip Menu |
 

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 111276
Status: resolved
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: ALTREUS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Content-Type in default_headers seems to be overwritten by POST and PUT
Download (untitled) / with headers
text/plain 1.3k
This is easier to show with Mechanize: my $mech = WWW::Mechanize->new( default_headers => HTTP::Headers->new( Content_Type => 'application/json', Accept => 'application/json', ) ); $mech->post('http://localhost:6000/', Content => encode_json({ user => 'test', password => 'password' }), ); I have determined that 'default_headers' is correctly forwarded to LWP here. LWP::UserAgent::new([...]/LWP/UserAgent.pm:28): 28: my $agent = delete $cnf{agent}; DB<1> x %cnf 0 'default_headers' 1 HTTP::Headers=HASH(0xebe47f0) 'accept' => 'application/json' 'content-type' => 'application/json' 2 'cookie_jar' 3 HASH(0xec817e8) empty hash 4 'agent' 5 'WWW-Mechanize/1.75' A tcpdump of this transaction shows that Content-Type was set to application/x-www-form-urlencoded: POST / HTTP/1.1 TE: deflate,gzip;q=0.3 Connection: TE, close Accept: application/json Accept-Encoding: gzip Host: localhost:6000 User-Agent: WWW-Mechanize/1.75 Content-Length: 37 Content-Type: application/x-www-form-urlencoded {"password":"password","user":"test"} This is also true of PUT, but I exemplified POST because Mechanize inherits this directly from LWP without interference, so I can be sure of the source of the issue.
Download (untitled) / with headers
text/plain 756b
On Mon Jan 18 09:40:38 2016, ALTREUS wrote: Show quoted text
> $mech->post('http://localhost:6000/', > Content => encode_json({ > user => 'test', > password => 'password' > }), > ); >
I forgot to mention that it works fine if you specify Content-Type at this point. $mech->post('http://localhost:6000/', Content => encode_json({ user => 'test', password => 'password' }), Content_Type => 'application/json' ); POST / HTTP/1.1 TE: deflate,gzip;q=0.3 Connection: TE, close Accept: application/json Accept-Encoding: gzip Host: localhost:6000 User-Agent: WWW-Mechanize/1.75 Content-Length: 37 Content-Type: application/json {"password":"password","user":"test"}
From: wolfsage [...] gmail.com
Download (untitled) / with headers
text/plain 309b
On Mon Jan 18 09:40:38 2016, ALTREUS wrote: Show quoted text
> This is also true of PUT, but I exemplified POST because Mechanize > inherits this directly from LWP without interference, so I can be sure > of the source of the issue.
Possible fix: https://github.com/libwww-perl/libwww-perl/pull/100 -- Matthew Horsfall (alh)
Download (untitled) / with headers
text/plain 394b
On Fri Dec 30 19:07:26 2016, wolfsage@gmail.com wrote: Show quoted text
> On Mon Jan 18 09:40:38 2016, ALTREUS wrote:
> > This is also true of PUT, but I exemplified POST because Mechanize > > inherits this directly from LWP without interference, so I can be sure > > of the source of the issue.
> > Possible fix: https://github.com/libwww-perl/libwww-perl/pull/100 > > -- Matthew Horsfall (alh)
Thanks, alh!


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.