From e3d17848f6963429f3bd69ddb4b01965ba8df448 Mon Sep 17 00:00:00 2001 From: CharleyWangHZ <57120416+CharleyWangHZ@users.noreply.github.com> Date: Fri, 25 Jun 2021 10:59:06 +0800 Subject: [PATCH 1/3] Update HttpSession.cpp --- src/Http/HttpSession.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index c8df9de7..b83b6ce4 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -37,6 +37,15 @@ void HttpSession::Handle_Req_HEAD(ssize_t &content_len){ //对于按需生成流的直播场景并不适用 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) { typedef void (HttpSession::*HttpCMDHandle)(ssize_t &); @@ -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("POST",&HttpSession::Handle_Req_POST); s_func_map.emplace("HEAD",&HttpSession::Handle_Req_HEAD); + s_func_map.emplace("OPTIONS",&HttpSession::Handle_Req_OPTIONS); }, nullptr); _parser.Parse(header); From 248c9e8f9ae2eacfa176e0fe1d571dd7097450c5 Mon Sep 17 00:00:00 2001 From: CharleyWangHZ <57120416+CharleyWangHZ@users.noreply.github.com> Date: Fri, 25 Jun 2021 10:59:56 +0800 Subject: [PATCH 2/3] Update HttpSession.h --- src/Http/HttpSession.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Http/HttpSession.h b/src/Http/HttpSession.h index 98549439..0cb4a366 100644 --- a/src/Http/HttpSession.h +++ b/src/Http/HttpSession.h @@ -105,6 +105,7 @@ private: void Handle_Req_GET_l(ssize_t &content_len, bool sendBody); void Handle_Req_POST(ssize_t &content_len); void Handle_Req_HEAD(ssize_t &content_len); + void Handle_Req_OPTIONS(ssize_t &content_len); bool checkLiveStream(const string &schema, const string &url_suffix, const function &cb); From 332e8fa18050b5ae7dbb288a4429adc92158a46e Mon Sep 17 00:00:00 2001 From: CharleyWangHZ <57120416+CharleyWangHZ@users.noreply.github.com> Date: Fri, 25 Jun 2021 11:17:21 +0800 Subject: [PATCH 3/3] Update HttpSession.cpp --- src/Http/HttpSession.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index b83b6ce4..aaf87fef 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -41,10 +41,7 @@ void HttpSession::Handle_Req_HEAD(ssize_t &content_len){ 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); + sendResponse(200, true); } ssize_t HttpSession::onRecvHeader(const char *header,size_t len) {