Implement an http server, and use fastcgi protocol to communicate with php-fpm when supporting php
To implement the get request, send QUERY_STRING and SCRIPT_FILENAME to php-fpm, and the server returns the result, which is normal here.
The post request is implemented by sending the content-length field and body content to the fastcgi server, and then the server returns the result. Like the following
Form code
<html>
<body>
<form action = "file.php" method = "POST" >
<input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
php code
<?php
var_dump($_POST['age']);
Parameters sent
SCRIPT_FILENAME : /home/tan/Demo/studyHttpd/htdocs/file/file.php
REQUEST_METHOD : POST
QUERY_STRING :
CONTENT_TYPE : application/x-www-form-urlencoded
CONTENT_LENGTH : 7
The body sent is , which is the content in the form
age=123
Why does php-fpm return NULL?
You print separately
$_POST
和$_REQUEST
that is: