2

I've got an application that sends relatively large POST requests to an Apache shared hosting.

On the server, there's a .php file with

file_get_contents("php://input")

that's supposed to read the POST raw body. It works as long as the POST body is less than ~16000 characters in length. If there are more, the above piece of code returns an empty string.

I'd like to have the entire body returned, regardless of its length.

  • By default, it is said there's a post_max_size = 64M setting in the server's php.ini. Setting it myself manually doesn't alleviate the issue.

  • The client-side code always works properly. The Content-Length header is set correctly as well.

  • Sending the POST via a HTML form and accessing it with $_POST['content'] server-side behaves in the same exact way.

John Smith
  • 3,863
  • 3
  • 24
  • 42

3 Answers3

2

The problme might be with the web server. You may try to up the body limit on your web server software. For example in Apache :

LimitRequestBody 

in Nginx :

client_max_body_size
Flunch
  • 21
  • 3
2

The solution was to create an empty folder named tmp in the public root. In most cases it most likely would be created automatically (if needed at all), however this hosting company's configuration is flawed, I believe.

John Smith
  • 3,863
  • 3
  • 24
  • 42
1

Try adding this all the way on top of your script:

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

You are most likely getting an error that you cannot see due to errors being disabled.

You can also try removing --with-curlwrapper from the PHP configuration and rebuilding it. file_get_contents returns empty string

Thrallix
  • 699
  • 5
  • 20