Use $_SERVER['CONTENT_LENGTH'] instead of getallheaders().

getallheaders() doesn't seem to be available on your PHP set-up, but getting header values from $_SERVER should work.