现在的位置: 首页 > 综合 > 正文

GoForms

2014年02月18日 ⁄ 综合 ⁄ 共 2710字 ⁄ 字号 评论关闭

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

【上篇】
【下篇】

抱歉!评论已关闭.