I'm trying to write an API that accepts PUT, PATCH and DELETE request methods and I was able to do so, but I was running into an issue where reading from php://input
is extremely slow. Parsing a request with a 970k gif file takes 10-12 seconds and from the logging I added, all that time is spent reading from php://input
$stream = fopen('php://input', 'r');
// Log stream opened
$raw_data = "";
while(!feof($stream)) {
$raw_data .= fread($stream, $headers['content-length']);
}
// Log stream read
fclose($stream);
The time between those two log entries, as I said, is 10-12 seconds. What am I doing wrong? Is there a php setting somewhere I need to change?
Thanks