Update HttpSession.cpp

This commit is contained in:
CharleyWangHZ 2021-06-25 10:59:06 +08:00 committed by GitHub
parent 92f879d703
commit e3d17848f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,15 @@ void HttpSession::Handle_Req_HEAD(ssize_t &content_len){
sendResponse(200, true); sendResponse(200, true);
} }
void HttpSession::Handle_Req_OPTIONS(ssize_t &content_len)
{
//暂时对OPTINS进行200 OK回复
KeyValue headerOut;
headerOut["Content-Type"] = "application/octet-stream";
sendResponse(200, true, nullptr, headerOut, nullptr, true);
}
ssize_t HttpSession::onRecvHeader(const char *header,size_t len) { ssize_t HttpSession::onRecvHeader(const char *header,size_t len) {
typedef void (HttpSession::*HttpCMDHandle)(ssize_t &); typedef void (HttpSession::*HttpCMDHandle)(ssize_t &);
static unordered_map<string, HttpCMDHandle> s_func_map; static unordered_map<string, HttpCMDHandle> s_func_map;
@ -45,6 +54,7 @@ ssize_t HttpSession::onRecvHeader(const char *header,size_t len) {
s_func_map.emplace("GET",&HttpSession::Handle_Req_GET); s_func_map.emplace("GET",&HttpSession::Handle_Req_GET);
s_func_map.emplace("POST",&HttpSession::Handle_Req_POST); s_func_map.emplace("POST",&HttpSession::Handle_Req_POST);
s_func_map.emplace("HEAD",&HttpSession::Handle_Req_HEAD); s_func_map.emplace("HEAD",&HttpSession::Handle_Req_HEAD);
s_func_map.emplace("OPTIONS",&HttpSession::Handle_Req_OPTIONS);
}, nullptr); }, nullptr);
_parser.Parse(header); _parser.Parse(header);