代码拉取完成,页面将自动刷新
// encode UTF-8
// @Author : Aged_cat
// @Date : 2021-05-04
#ifndef HTTP_RESPONSE_H
#define HTTP_RESPONSE_H
#include <unordered_map>
#include <fcntl.h> //open
#include <unistd.h> //close
#include <sys/stat.h> //stat
#include <sys/mman.h> //mmap,munmap
#include <assert.h>
#include "buffer.h"
class HTTPresponse
{
public:
HTTPresponse();
~HTTPresponse();
void init(const std::string& srcDir,std::string& path,bool isKeepAlive=false,int code=-1);
void makeResponse(Buffer& buffer);
void unmapFile_();
char* file();
size_t fileLen() const;
void errorContent(Buffer& buffer,std::string message);
int code() const {return code_;}
private:
void addStateLine_(Buffer& buffer);
void addResponseHeader_(Buffer& buffer);
void addResponseContent_(Buffer& buffer);
void errorHTML_();
std::string getFileType_();
int code_;
bool isKeepAlive_;
std::string path_;
std::string srcDir_;
char* mmFile_;
struct stat mmFileStat_;
static const std::unordered_map<std::string, std::string> SUFFIX_TYPE;
static const std::unordered_map<int, std::string> CODE_STATUS;
static const std::unordered_map<int, std::string> CODE_PATH;
};
#endif //HTTP_RESPONSE_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。