Brad Brad - 1 month ago 9
PHP Question

Check request headers before sending 100 Continue

With PHP, is it possible to check the request headers on that request that contains

Expect: 100-Continue
within the request headers, before sending that
100 Continue
and then getting the actual request body?

That is, if someone wants to upload a file, I want to inspect the request headers and possibly reject the request before the client has to upload the whole thing.

Answer

That is not possible, your webservice (nginx or apache) will handle the 100-continue before triggering your PHP script, so there is nothing in PHP you can do to affect the result of that part of the HTTP protocol.

Your only solution would be to manually build a full HTTP server in PHP but that is not worth it.

If you control the client, you should simply use a HEAD request before making the actual request, that way you can handle the response in PHP.