My understanding on CGI and how to support it in http server – Ba Jian, 2008-12-30
CGI, the acronym of “common gatway interface”, can be used by http server to extend its ability for more active contents. Usually, an exe file or a script file can be called by http server to provide dynamic web page. Hense , almost all compiling languages can be used to write CGI application. And almost all script languages can be used to write CGI applications.
The interface between CGI exe ( or script) file can be Depicted as: 1) WebPage Specified CGI Executable (or Script) File, or You Can Directly Specify It in url, like: http://my_server_name/cgi-bin/helloworld.exe
< wbr> for example, webpage: http://computer.bowenwang.com.cn/simpleform.htm if you checked the source code, you can find:
< /span>
A super-simple form
< br style="color: rgb(0, 0, 102);"> > wbr> Enter Your Name: Name” size=20 maxlength=50> span>
Where: 1.1) “ < wbr> in http url, and post to http server 1.2) “
For example, if you input “ba_jian_ni_hao_a” in the form presented by http://computer.bowenwang.com.cn/simpleform.htm The final url posted to http server will be: < br> http://computer.bowenwang.com.cn/cgi-bin/ simpleform.cgi? Name=ba_jian_ni_hao_a Th e general format can be written as: http://http_server/cgi-bin/cgi_exe?name1=value1&name2=value2&name3=value3&name4=value4&… Where, value= name3, value= name 3, value= 4, value= 4 name ?” is used to link cgi executable file and parameters “&” is used to link different parameters “%” means there are binary data after it 3) Data transfer: from http server to cgi executeable file CGI executable file can use STDIN to get coressponding parameters. Suppose c/C++ language is used, getchar() can be used to get paramters. By the way, special characters such as blank characters is encoded using %xx. “+” is encoded as”. 4) Data transfer : from cgi executable file to http server Suppose C/C++ is used, printf() can be used to write output string. Http server can intercept STDOUT of CGI executable application using solution like pipe. Then all output of CGI executable file can be intercepted by http server. 5) Data transfer: from http server to web-browser (client) Since http server can directly intercept CGI output, it can be simply forward to http client through http channel. In conclusion, to write a simple http server which just supports static webpage is quite simple, the http server just need map http request to local file. In general, two days should be enough. To let your simple http server support CGI is still simple, you just need to create communication channel between http server and CGI executable files, and use http server to intercept output of CGI executable file and forward to http client-web browser. Actually, the principles of ASP/JSP/PHP are quite similar to CGI. The difference is CGI executable file is run by OS, so you may find there are many many instance of active processes of your cgi execuable file. However ASP/JSP/PHP is interpreted by engine in http server. ========= ====================== ================================================== =================== References: http://blog.ligj.eol.cn/115# http://blog.csdn.net/ahcen001/archive/2006 /08/31/1147618.aspx http://initiative.yo2.cn/archives/360673 http://cn.blurtit.com/q420414.html http://bloggermap.org/rss/readblog/5308 http:/ /computer.bowenwang.com.cn/cgi4.htm
My understanding on CGI and how to support it in http server font> – Ba Jian, 2008-12-30
C< /font>GI, the acronym of “common gatway interface”, can be used by http server to extend its ability for more active contents. Usually, an exe file or a script file can be called by http server to provide dynamic web page. Hense, almost all compiling languages can be used to write CGI application. And almost all script languages can be used to write CGI applications.
The interface between CGI exe (or sc ript) file can be depicted as:
1) webpage specified cgi executable ( or script) file,or you can directly specify it in url, like: http://my_server_name/cgi-bin/helloworld.exe
for example, webpage: http://computer.bowenwang.com.cn/simpleform.htm if you checked the source code, you can find:
< wbr>
A super-simple form
wbr> > wbr> Enter Your Name: Name” size=20 maxlength=50>
< wbr> < wbr>< WBR> html> span> Where: 1.1) “ wbr> in http url, and post to http server 1.2) “
For example, if you input “ba_jian_ni_hao_a” in the form presented by < wbr> http://computer.bowenwang.com.cn/simpleform.htm The final url posted to http server will be: wbr> http://computer.bowenwang.com.cn/cgi-bin/ simpleform.cgi? Name=ba_jian_ni_hao _a The general format can be written as: http://http_server/cgi-bin/cgi_exe?name1=value1&name2=value2&name3=value3&name4=value4&…, value= name= name 4, value= name= name 3, value 4, value= name= name 3, value 4 “?” is used to link cgi executable file and parameters “&” is used to link different parameters “&” is used to link different parameters “%” means there are binary data after it 3) Data transfer: from http server to cgi executeable file CGI executable file can use STDIN to get coressponding parameters. Suppose c/C++ language is used, getchar() can be used to get paramters. By the way, special characters such as blank characters is encoded using %xx. “+” is encoded as”. 4) Data transfer: from cgi executable file to http server Suppose C/C++ is used, printf() can be used to write output string. Http server can intercept STDOUT of CGI executable application using solution like pipe. Then Then all output of CGI executable file can be intercepted by http server. 5) Data transfer: from http server to web-browser (client) Since http server can directly intercept CGI output, it can be simply forward to http client through http channel. In conclusion, to write a simple http server which just supports static webpage is quite simple, the http server just need map http request to local file. In general, two days should be enough. To let your simple http server support CGI is still simple, you just need to create communication channel between http server and CGI executable files, and use http server to intercept output of CGI executable file and forward to http client-web browser. Actually, the principles of ASP/JSP/PHP are quite similar to CGI .The difference is CGI executable file is run by OS, so you may find there are many many instance of active processes of your cgi execuable file. However ASP/JSP/PHP is interpreted by engine in http server. ====== ============ ================================================== =============================== References: http://blog.ligj.eol.cn/115# http: //blog.csdn.net/ahcen001/archive/2006/08/31/1147618.aspx http://initiative.yo2.cn/archives/360673 http://cn.blurtit.com/q420414.html http:/ /bloggermap.org/rss/readblog/5308 http://computer.bowenwang.com.cn/cgi4.htm
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist] SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1658 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC