代码拉取完成,页面将自动刷新
#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;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。