Ben Harcourt
Ben Harcourt

Reputation: 31

Apache+PHP Truncated Post/Upload

I've been chasing down a bug that has been affecting image uploads to a website on our development platform (haven't been able to make it happen in live yet).

The synopsis is:

POST content larger than ~20KB gets inconsistently truncated.

I haven't yet been able to figure out exactly at what point that happens. I am confident that the data is all transmitted to Apache, but I am not sure if it receives it all, whether some of it is not passed to PHP, or whether something else is happening.

Steps I have taken thus far:

The precise behaviour I am seeing is somewhat confusing. As part of the debugging, I examined

echo strlen( file_get_contents( 'php://input' ) );

The value changed with each attempt, regardless of the files used. The largest value I have seen is approximately 500KB, the lowest about 20KB.

I have been able to fix this in one case (100% success rate over 10 attempts), by using a client that ran only in HTTP/1.0 (rather than HTTP/1.1).

Using that as a lead, I have attempted to use the force-downgrade-1.0 and related directives, but those affect the response rather than the request.

Upvotes: 2

Views: 1354

Answers (1)

Ben Harcourt
Ben Harcourt

Reputation: 31

Reason:

apache.conf had the directive

Timeout 0

This caused Apache HTTPD to wait 0 seconds for the post data, rather than indefinitely as I had expected. Setting Timeout to a large number of seconds in the Development environment solved this issue.

http://httpd.apache.org/docs/2.2/mod/core.html#timeout doesn't specify semantics for Timeout 0, so I assume it is interpreted literally.

Upvotes: 1

Related Questions