How do web servers populate $ _POST & $ _GET?

I am writing a Java web server, and now I can process .HTML files normally, but it is difficult for me to understand how to process .PHP files that require $ _POST and $ _GET.

How do web servers typically populate these arrays? It is impossible to fill them using the command line from what I can say, since I initially thought about passing stdout exec ("php whatever.php some $ _get args), but this is not possible without physically changing the php code to explode args and filling them in $ _GET, which I do not want to do - I want to do it the way the web servers do.

Does anyone have any suggestions on how web servers do such things?

+4
source share
1 answer

You can use the interface with PHP through the Common Gateway Interface (CGI), which boils down to creating a group of environment variables and then calling PHP.

REQUEST_METHOD="GET" QUERY_STRING="param1=value1&param2=value2" 

The CGI protocol is defined in RFC 3875 .

+5
source

Source: https://habr.com/ru/post/1369344/


All Articles