https://sourceforge.net/projects/tinyhttpd/files/ 标准源码
https://github.com/nengm/Tinyhttpd 测试所有功能都正常
1. 测试工程源码 相对 标准源码 做了如下修改:
httpd.c
Makefile
htdocs目录下的.cgi文件要加可执行权限
2 .cgi页面请求响应处理的核心函数—— execute_cgi( )
其中的父子线程是按如下图方式来协作完成响应页面的生成与传递
3. 运行httpd测试效果
make构建程序
./httpd启动程序
浏览其中访问 localhost:端口号
如果直接运行"perl color.cgi"需要一点点修改:
#!/usr/local/bin/perl -Tm
改为:
#!/usr/bin/perl
use warnings;
use strict;
说明:
The "-T" is tainting (it means input is marked as "not trusted" until you check it's format).
The "-w" turns warnings on.
参考:
https://www.cnblogs.com/tanxing/p/6791812.html TinyHTTPd源码分析
https://www.cnblogs.com/qiyeboy/p/6296387.html HTTP服务器的本质:tinyhttpd源码分析及拓展
https://www.cnblogs.com/nengm1988/p/7816618.html Tinyhttpd精读解析