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