1 Star 0 Fork 1

岳彪. / http

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
test.cc 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <sstream>
#include "Util.hpp"
#include "log.hpp"
// #include "HttpServer.hpp"
#include "HttpServer.hpp"
using namespace std;
int main()
{
auto hander = [&](const HttpRequest &req, HttpResponse &rsp)
{
logMessage(INFO, "hander");
};
HttpServer httpServer(8080, "output/wwwroot");
httpServer.setGet("/s", hander);
httpServer.run();
// 文件大小获取测试
// struct stat st;
// stat("www/a/index.html", &st);
// cout << st.st_size << endl;
// FILE *file = fopen("www/a/index.html", "rb");
// fseek(file, 0, SEEK_END);
// long size = ftell(file);
// cout << size << endl;
// int fd = open("test.txt", O_RDONLY);
// int fd_out = open("out.txt", O_WRONLY);
// while (true)
// {
// cout << "once" << endl;
// ssize_t size = sendfile(fd_out, fd, NULL, 100);
// if (size == 0)
// {
// break;
// }
// }
// string s = "GET\r/\r\ncccc\n\n";
// int pos = 0;
// while (true)
// {
// string header;
// pos = Util::readLine(s, header, pos);
// cout << header << endl;
// // cout << header << endl;
// if (pos == 0) // 没有读到换行符,说明报文不完整
// {
// }
// if (header.size() == 0) // 读到空行,报头部分结束
// {
// break;
// }
// }
// string methord;
// string uri;
// string version;
// string ccc;
// stringstream ss(s);
// ss >> methord >> uri >> version >> ccc;
// cout << methord << endl;
// cout << uri << endl;
// cout << version << endl;
// cout << ccc << endl;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/Y_future/http.git
git@gitee.com:Y_future/http.git
Y_future
http
http
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891