[dancer-users] "Route exception: Bad Content-Length: maybe client disconnect?" with JSON POST and request->content

Lennart Hengstmengel lennart at farenji.net
Fri Jul 22 12:38:01 BST 2016

Hi all,

I'm running into an issue that looks like a bug, but I'm unsure where it 
comes from. Could be in Dancer2, but maybe in Plack::Request, or even in 
Plack::Test, HTTP::Request, or somewhere else. I'm kinda lost in the 
woods. I was hoping that a mind greater than mine can shed some light on 

I get an error "Route exception: Bad Content-Length: maybe client 
disconnect? (xx bytes remaining)" where xx is the total content length 
of the request body.
But only under the following conditions:

- (valid) JSON POST to a Dancer2 app
- the app is configured with serializer = JSON
- in the route there's a call to: request->content
- using Plack::Test and HTTP::Request

Attached is a minimal test to demonstrate the issue. Test no 5 fails.

I cannot reproduce this issue when using f.e. curl, this call works 
without errors:

     curl --data-binary '{ "foo": "123" }' --header 'Content-type: 
application/json' http://localhost:3000/nok

I am using the latest version of Dancer (0.200003) and also latest CPAN 
versions of Plack and HTTP::Request.

Any insights?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: json_post_dancer2_test.pl
Type: application/x-perl
Size: 1256 bytes
Desc: not available
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20160722/f9240e89/attachment.bin>

More information about the dancer-users mailing list