I have a server that accepts HTTP POSTs from an 3rd Party, then returns either a 200 or 500.
The 3rd Party is not under my control, and sometimes sends very large POSTs, e.g. 40MB.
These POSTs cause my PHP code to run out of memory, which I can't catch, and so apache sends a 500.
The API retries that POST forever, and doesn't send new data, so this is a problem.
I've tried various things, but have ended up thinking that if I could have .htaccess just return a 200 and do nothing else, if the content_length was > X, then this would at least buy me time to restructure how this works.
So…
Is it possible to write a rule in .htaccess such that if content_length > X, it returns a 200?
I don't like the idea of faking an "everything OK" when it's not. Depending on your environment, you might have multiple approaches:
php_value memory_limit 100M
in.htaccess
or similar inphp.ini
Increase the memory PHP may use only for this client. Try something like this (untested,
192.168.1.0/24
is the address of the remote system(s)):Use your idea if all else fails, something like this:
This is also untested and unlikely to work as is, but the core of it is the
RewriteCond %{HTTP:Content-Length}
part.