http://www.perlmonks.org?node_id=1043645


in reply to Trouble with LWP, post request and XML data

The nameless monk is correct in that the Net-HTTP changelog does list several changes with regard to chunked encoding in 6.04, so upgrading to the latest version (currently 6.06) might help you out.

Your problem may stem from the fact that the HTTP response you gave included this header:

Transfer-Encoding: chunked

However, the body of the response is not formatted as a chunked encoding. In chunked encodings, the first line (and various subsequent lines, but I won't go into the details) is expected to be an integer, giving the size of a chunk in bytes. However, the first line of the response body is:

<?xml version="1.0" encoding="UTF-8"?>

Hence the message, "Bad chunk-size in HTTP response".

So the HTTP response is broken. If you have the option of fixing it at that end, that's what you should do. If you can't fix it at that end, then there are a couple of options: patch LWP to cope with the broken HTTP response (and you might get this accepted upstream if you can show it's a common problem, and your patch doesn't harm non-broken HTTP responses); or set up a proxy that fixes broken chunked encoding and make all your requests via the proxy.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name