登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Code@Pig Home

喜欢背着一袋Code傻笑的Pig .. 忧美.欢笑.记忆.忘却 .之. 角落

 
 
 

日志

 
 

[web] 关于CGI  

2011-01-09 14:33:10|  分类: web |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
browser <==> webserver <==> cgi program

以前还真没认真去看下CGI到底如何工作的。其实很简单:
  1. webserver 接到请求,则 create process 去执行 cgi program
  2. 将一些参数作为'环境变量'传给 cgi program
  3. cgi program 处理完逻辑后,把生成的网页写到 stdout
  4. webserver 把 stdout 的内容丢给 browser

不过 nginx 不支持"create process 去执行 cgi program",所以就不演示了。

这有个更详细的说明,直接贴出来:
1. For each request, the server creates a new process and the process initializes itself.
2. The Web server passes the request information (such as remote host, username, HTTP headers, etc.) to the CGI program in environment variables.
3. The Web server sends any client input (such as user-entered field values from an HTML form) to the CGI program's standard input.
4. The CGI program writes any output to be returned to the client on standard output. Error information written to standard error is logged by the Web server.
5. When the CGI process exits, the request is complete.
  评论这张
 
阅读(896)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018