<tfoot id='fzGrD'></tfoot><legend id='fzGrD'><style id='fzGrD'><dir id='fzGrD'><q id='fzGrD'></q></dir></style></legend>

    1. <i id='fzGrD'><tr id='fzGrD'><dt id='fzGrD'><q id='fzGrD'><span id='fzGrD'><b id='fzGrD'><form id='fzGrD'><ins id='fzGrD'></ins><ul id='fzGrD'></ul><sub id='fzGrD'></sub></form><legend id='fzGrD'></legend><bdo id='fzGrD'><pre id='fzGrD'><center id='fzGrD'></center></pre></bdo></b><th id='fzGrD'></th></span></q></dt></tr></i><div id='fzGrD'><tfoot id='fzGrD'></tfoot><dl id='fzGrD'><fieldset id='fzGrD'></fieldset></dl></div>

    2. <small id='fzGrD'></small><noframes id='fzGrD'>

          <bdo id='fzGrD'></bdo><ul id='fzGrD'></ul>

      1. 如何将 POST 数据传递给 PHP-CGI?

        时间:2023-10-12
          <tbody id='6u16U'></tbody>

            <legend id='6u16U'><style id='6u16U'><dir id='6u16U'><q id='6u16U'></q></dir></style></legend>
            <tfoot id='6u16U'></tfoot>
              <bdo id='6u16U'></bdo><ul id='6u16U'></ul>

                1. <small id='6u16U'></small><noframes id='6u16U'>

                2. <i id='6u16U'><tr id='6u16U'><dt id='6u16U'><q id='6u16U'><span id='6u16U'><b id='6u16U'><form id='6u16U'><ins id='6u16U'></ins><ul id='6u16U'></ul><sub id='6u16U'></sub></form><legend id='6u16U'></legend><bdo id='6u16U'><pre id='6u16U'><center id='6u16U'></center></pre></bdo></b><th id='6u16U'></th></span></q></dt></tr></i><div id='6u16U'><tfoot id='6u16U'></tfoot><dl id='6u16U'><fieldset id='6u16U'></fieldset></dl></div>
                3. 本文介绍了如何将 POST 数据传递给 PHP-CGI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  更新:

                  出于绝望,我在 shell 中执行了以下操作:

                  In a fit of desperation, I did the following in a shell:

                  REDIRECT_STATUS=true
                  SCRIPT_FILENAME=/var/www/...
                  REQUEST_METHOD=POST
                  GATEWAY_INTERFACE=CGI/1.1
                  export REDIRECT_STATUS
                  export SCRIPT_FILENAME
                  export REQUEST_METHOD
                  export GATEWAY_INTERFACE
                  echo "test=1" | php-cgi
                  

                  ...并且仍然没有 $_POST 变量出现在这个输出中:

                  ...and STILL no $_POST variables are showing up in the output of this:

                  <?php var_dump($_POST); ?>
                  

                  <小时>

                  我正在尝试创建一个与 php-cgi 二进制文件接口的小型网络服务器.然而,事情并没有那么顺利.php-cgi 二进制文件正确处理 GET 请求.当涉及 POST 请求时,$_POST 数组是空的,即使事情正在被 POST.


                  I am trying to create a small webserver that interfaces with the php-cgi binary. However, things aren't going so well. The php-cgi binary correctly handles GET requests. When it comes to POST requests, the $_POST array is empty, even when things are getting POSTed.

                  我检查了输入 php-cgi 二进制文件的 HTTP 标头,它们确实包含 POST 数据和 Content-type: application/x-www-form-urlencoded 标头.

                  I've checked the HTTP headers being fed into the php-cgi binary and they do indeed include the POST data and the Content-type: application/x-www-form-urlencoded header.

                  是什么让 php-cgi 二进制文件无法看到请求中包含 POST 数据?

                  What could be keeping the php-cgi binary from seeing that there's POST data included in the request?

                  我正在取得进展,我从 PHP 源代码:

                  I'm making progress, I've dug up some stuff from the PHP source code:

                  • /sapi/cgi/cgi_main.c:

                  468: static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)

                  (我不知道从哪里调用这个函数.)

                  (I have no idea where this function is invoked from.)

                  阅读下面的答案后,我尝试了:

                  After reading the answer below, I tried:

                  <?php
                  
                  var_dump($HTTP_RAW_POST_DATA);
                  
                  ?>
                  

                  ...产生输出:

                  NULL
                  

                  ...表示有更奇怪的东西在这里工作.

                  ...indicating that something even stranger is at work here.

                  我越来越近了...我在 /main/php_content_types.c:

                  I'm getting closer... I found this function in /main/php_content_types.c:

                  SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)

                  SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)

                  ...它似乎是处理 POST 请求的代码.

                  ...and it seems to be the code that processes POST requests.

                  推荐答案

                  终于想通了:

                  显然需要设置 CONTENT_LENGTH 环境变量.

                  Apparently the CONTENT_LENGTH environment variable needs to be set.

                  添加:

                  CONTENT_LENGTH=6
                  export CONTENT_LENGTH
                  

                  我上面的例子使它正常工作!

                  to my example above causes it to work properly!

                  这篇关于如何将 POST 数据传递给 PHP-CGI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:php http 请求内容原始数据 enctype=multipart/form-data 下一篇:为什么你不应该使用 mysql_fetch_assoc 超过 1 次?

                  相关文章

                  <legend id='08Z4X'><style id='08Z4X'><dir id='08Z4X'><q id='08Z4X'></q></dir></style></legend>
                4. <small id='08Z4X'></small><noframes id='08Z4X'>

                5. <i id='08Z4X'><tr id='08Z4X'><dt id='08Z4X'><q id='08Z4X'><span id='08Z4X'><b id='08Z4X'><form id='08Z4X'><ins id='08Z4X'></ins><ul id='08Z4X'></ul><sub id='08Z4X'></sub></form><legend id='08Z4X'></legend><bdo id='08Z4X'><pre id='08Z4X'><center id='08Z4X'></center></pre></bdo></b><th id='08Z4X'></th></span></q></dt></tr></i><div id='08Z4X'><tfoot id='08Z4X'></tfoot><dl id='08Z4X'><fieldset id='08Z4X'></fieldset></dl></div>
                  <tfoot id='08Z4X'></tfoot>

                        <bdo id='08Z4X'></bdo><ul id='08Z4X'></ul>