GoForms

GoForms™作为GoAhead WebServer的一部分,是一种高效的表单处理技术,它在内存中运行且无需为每个浏览器连接创建新进程。GoForms通过共享地址空间直接访问完整的请求上下文,并自动解析所有POST和查询数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GoForms™

The GoAhead WebServer implements the standard Common Gateway Interface (CGI) as an in-memory forms processor called GoForms™. Old style CGI processing results in the creation of a new process for every request to a CGI URL. As CGI is often the primary means of implementing user input, this is slow and cumbersome. GoForms is a more suitable solution for embedded systems that demand compact, high performance solutions.

GoAhead WebServer 提供一个标准的普通网管接口作为内存表格处理,我们称之为GoForms.。老版本的CGI处理会导致在对于每一个CGIURL的请求产生一个新的进程。因为CGI通常作为执行用户输入的首要方式,同时它也是缓慢和额繁琐的。嵌入式系统需要一个结构紧凑高性能的的解决方案,而GoForms 就是一个最佳选择。

GoForm procedures run in-memory without creating a new process for each browser connection. By sharing the address space with the GoAhead WebServer, GoForms procedures can directly access the full request context. The GoForm handler also automatically decodes and parses all POST and query data for easy access. A convenient API (see websGetVar) permits easy access to CGI variables.

GoForms 运行在内存中无需给每一个浏览器链接创建一个新的进程。通过与GoAhead WebServer分享地址空间,GoForms 可以直接访问全部请求内容。GoForms 处理程序也会自动的进行解码,继续所有的POST以及查询每一个访问数据。一个合适的API允许简易的访问CGI变量。

GoForms is implemented as a URL Handler which interprets URLs that begin with "/goform". The URL segment following "goform" defines the form name with query details appended to the URL. For example:

/goform/myForm?name=John&age=30           

convenient 用作URL Handler去解释以/goform开头的URLURL段紧跟着goform会定义表格名字附加查询细节。例如:

/goform/myForm?name=John&age=30

This will call the GoForm procedure "myForm" and automatically decode the query string "name=John&age=30" and define GoForm variables called "name" and "age". In addition to POST and query data, the standard CGI variables are also defined.

它将会调用GoForm处理myForm以及动态的解码来查询字符串"name=John&age=30",同时定义GoForm 变量name和age。另外POST、查询数据以及标准的CGI变量也会被定义。

GoForm procedures are defined by the websFormDefine API call and conform to the following prototype:

GoForm 处理过程在websFormDefine  API里被定义。 

void myForm(webs_t wp, char_t *path, char_t *query)

{

    websHeader(wp);

    websWrite(wp, "Name %s", websGetVar(wp, "name", "")); 

    websWrite(wp,  "Age %s", websGetVar(wp, "age", ""));

    websFooter(wp);

    websDone(wp, 200);

}

The GoForm procedure is responsible for writing the HTTP header and HTML document content back to the user's browser. websHeader creates a standard HTTP header with initial HTML tags. websFooter closes the document with a closing HTML tag. Inside the GoForm procedure, websGetVarwebsRedirectwebsWrite, and websWriteBlock are some of the most useful API calls.

GoForm 负责写HTTP头和HTML文档的内容,然后返回给用户浏览器。websHeader创建一个标准的HTTP头,附带初始化HTML标志。websFooter 用一个HTML标志来关闭文档。在GoForm 处理过程中,websGetVarwebsRedirectwebsWrite, and websWriteBlock是非常有用的几个API



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值