【C】轻量级HTTP Server/Client实现:Tinyhttpd精读解析

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精读解析

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值