如何检索表格和QUOT; POST"通过用C语言编写的cgi-bin程序数据 [英] How to retrieve form "POST" data via cgi-bin program written in C

查看:254
本文介绍了如何检索表格和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.

这篇关于如何检索表格和QUOT; POST"通过用C语言编写的cgi-bin程序数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆