如何检索表格和QUOT; POST"通过用C语言编写的cgi-bin程序数据

如何检索表格和QUOT; POST"通过用C语言编写的cgi-bin程序数据

问题描述:

我试图用C语言编写的程序从HTML表单检索POST数据。

I am trying to retrieve POST data from html form using program written in C.

目前我使用的时刻:

char *formdata = getenv("QUERY_STRING");
if(formdata == NULL) /* no data retrieved */

这似乎是工作的罚款与形式GET的方法,但不是以POST的方法。我该如何找回POST数据?

This seems to be working fine with form "GET" method but not with "POST" method. How do I retrieve POST data?

POST数据附加到请求头,双换行符后。在CGI-BIN的环境中,你从标准输入读取。

POST data is appended to the request header, after a double newline. In a CGI-BIN environment, you read it from STDIN.

但是要注意,服务器的不需要在POST数据的最后送你一个EOF字符(或终止指标)。从来没有超过CONTENT_LENGTH字节读更多。

Be warned that the server IS NOT REQUIRED to send you an EOF character (or some termination indicator) at the end of the POST data. Never read more than CONTENT_LENGTH bytes.