• 大小: 117KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-29
  • 语言: C/C++
  • 标签: C  HTTP  WEB  CGI  URL  

资源简介

测试方式(依次在浏览器输入一下内容进行不同情形的测试): 127.0.0.1:9988 127.0.0.1:9988/hehe.html 127.0.0.1:9988/login.html 127.0.0.1:9988/haha?x=10&y=20 也可以下载fiddler工具进行更全面的模拟测试! 1、支持GET/POST方法 2、支持CGI 3、支持错误返回 4、支持chunked数据的解析 缺点: 1、支持的方法不够全面 2、CGI实现不够科学,可以尝试使用FASTCGI 3、不支持https 4、不支持回应chunked数据 感兴趣的同学可以继续完善相关功能.

资源截图

代码片段和文件信息

#include 
#include 
using namespace std;
#define  MAXLINE  1024

int main()
{
char *buf *p;
char name[MAXLINE] passwd[MAXLINE] content[MAXLINE];

/* Extract the two arguments */
if ((buf = getenv(“QUERY_STRING“)) != NULL) {
p = strchr(buf ‘&‘);
if (p){
*p = ‘\0‘;
strcpy(passwd p + 1);
}
else{
strcpy(passwd “null“);
}
strcpy(name buf);
}
else{
printf(“---------error arg!----------“);
fflush(stdout);
exit(1);
return 0;
}


/* Make the response body */
_snprintf_s(content MAXLINE _TRUNCATE “welcome to my web:%s and %s\r\n“ name passwd);
_snprintf_s(content MAXLINE _TRUNCATE “%sthis is a dynamic web!\r\n“ content);

_snprintf_s(content MAXLINE _TRUNCATE “%sthanks for visiting!\r\n“ content);

printf(“%s“ content);
fflush(stdout);
exit(0);
return 0;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2943  2017-10-12 15:24  webcgi\Debug\webcgi.log

     文件        650  2017-10-12 15:24  webcgi\Debug\webcgi.tlog\cl.command.1.tlog

     文件      12194  2017-10-12 15:24  webcgi\Debug\webcgi.tlog\CL.read.1.tlog

     文件        460  2017-10-12 15:24  webcgi\Debug\webcgi.tlog\cl.write.1.tlog

     文件       1010  2017-10-12 15:24  webcgi\Debug\webcgi.tlog\link.command.1.tlog

     文件       3298  2017-10-12 15:24  webcgi\Debug\webcgi.tlog\link.read.1.tlog

     文件        380  2017-10-12 15:24  webcgi\Debug\webcgi.tlog\link.write.1.tlog

     文件        168  2017-10-12 15:24  webcgi\Debug\webcgi.tlog\webcgi.lastbuildstate

     文件        880  2017-10-12 15:24  webcgi\main.cpp

     文件       4139  2017-10-11 17:47  webcgi\webcgi.vcxproj

     文件        956  2017-10-11 17:14  webcgi\webcgi.vcxproj.filters

     文件        165  2017-10-11 17:14  webcgi\webcgi.vcxproj.user

     文件       1014  2017-10-11 16:33  webserver\Debug\webserver.Build.CppClean.log

     文件         53  2017-10-07 12:36  webserver\Debug\webserver.lastbuildstate

     文件        706  2017-10-12 15:24  webserver\Debug\webserver.log

     文件       1290  2017-10-12 15:08  webserver\Debug\webserver.tlog\cl.command.1.tlog

     文件      61558  2017-10-12 15:08  webserver\Debug\webserver.tlog\CL.read.1.tlog

     文件       1726  2017-10-12 15:08  webserver\Debug\webserver.tlog\CL.write.1.tlog

     文件       1158  2017-10-12 15:08  webserver\Debug\webserver.tlog\link.command.1.tlog

     文件       3718  2017-10-12 15:08  webserver\Debug\webserver.tlog\link.read.1.tlog

     文件        498  2017-10-12 15:08  webserver\Debug\webserver.tlog\link.write.1.tlog

     文件        168  2017-10-12 15:24  webserver\Debug\webserver.tlog\webserver.lastbuildstate

     文件      28383  2017-10-12 15:08  webserver\HttpServer.cpp

     文件       4875  2017-10-12 11:15  webserver\HttpServer.h

     文件       5508  2017-10-12 10:00  webserver\main.cpp

     文件       4318  2017-10-11 16:33  webserver\webserver.vcxproj

     文件       1245  2017-10-11 16:33  webserver\webserver.vcxproj.filters

     文件        489  2017-10-09 11:15  webserver\webserver.vcxproj.user

     文件       9118  2017-10-04 13:42  webserver\复件 HttpServer.cpp

     文件       1317  2017-10-02 19:13  webserver\复件 HttpServer.h

............此处省略69个文件信息

评论

共有 条评论