diff --git a/examples/simple_example_test/main.cc b/examples/simple_example_test/main.cc index f22fd16a..d6046816 100644 --- a/examples/simple_example_test/main.cc +++ b/examples/simple_example_test/main.cc @@ -437,7 +437,7 @@ void doTest(const HttpClientPtr &client, // LOG_DEBUG << resp->getBody(); auto allow = resp->getHeader("allow"); if (resp->statusCode() == k200OK && - allow == "GET,HEAD,POST,PUT,DELETE,OPTIONS") + allow == "GET,HEAD,POST,PUT,DELETE,OPTIONS,PATCH") { outputGood(req, isHttps); } diff --git a/lib/src/HttpAppFrameworkImpl.cc b/lib/src/HttpAppFrameworkImpl.cc index 4b3944b8..9cd8e346 100644 --- a/lib/src/HttpAppFrameworkImpl.cc +++ b/lib/src/HttpAppFrameworkImpl.cc @@ -739,7 +739,7 @@ void HttpAppFrameworkImpl::onAsyncRequest( { auto resp = HttpResponse::newHttpResponse(); resp->setContentTypeCode(ContentType::CT_TEXT_PLAIN); - resp->addHeader("ALLOW", "GET,HEAD,POST,PUT,DELETE,OPTIONS"); + resp->addHeader("ALLOW", "GET,HEAD,POST,PUT,DELETE,OPTIONS,PATCH"); resp->setExpiredTime(0); callback(resp); return; diff --git a/lib/src/HttpControllersRouter.cc b/lib/src/HttpControllersRouter.cc index 351c8ba2..56e5e498 100644 --- a/lib/src/HttpControllersRouter.cc +++ b/lib/src/HttpControllersRouter.cc @@ -644,6 +644,10 @@ void HttpControllersRouter::doPreHandlingAdvices( { methods.append("DELETE,"); } + if (routerItem.binders_[Patch] && routerItem.binders_[Patch]->isCORS_) + { + methods.append("PATCH,"); + } methods.resize(methods.length() - 1); resp->addHeader("ALLOW", methods); auto &origin = req->getHeader("Origin"); diff --git a/lib/src/HttpRequestImpl.cc b/lib/src/HttpRequestImpl.cc index 1113c41b..854883fc 100644 --- a/lib/src/HttpRequestImpl.cc +++ b/lib/src/HttpRequestImpl.cc @@ -177,6 +177,9 @@ void HttpRequestImpl::appendToBuffer(trantor::MsgBuffer *output) const case Options: output->append("OPTIONS "); break; + case Patch: + output->append("PATCH "); + break; default: return; } diff --git a/lib/src/HttpSimpleControllersRouter.cc b/lib/src/HttpSimpleControllersRouter.cc index ac1494f3..caf03bfc 100644 --- a/lib/src/HttpSimpleControllersRouter.cc +++ b/lib/src/HttpSimpleControllersRouter.cc @@ -320,6 +320,10 @@ void HttpSimpleControllersRouter::doPreHandlingAdvices( { methods.append("DELETE,"); } + if (routerItem.binders_[Patch] && routerItem.binders_[Patch]->isCORS_) + { + methods.append("PATCH,"); + } methods.resize(methods.length() - 1); resp->addHeader("ALLOW", methods); diff --git a/lib/src/WebsocketControllersRouter.cc b/lib/src/WebsocketControllersRouter.cc index 76680f89..c938241a 100644 --- a/lib/src/WebsocketControllersRouter.cc +++ b/lib/src/WebsocketControllersRouter.cc @@ -265,6 +265,10 @@ void WebsocketControllersRouter::doControllerHandler( { methods.append("DELETE,"); } + if (routerItem.binders_[Patch] && routerItem.binders_[Patch]->isCORS_) + { + methods.append("PATCH,"); + } methods.resize(methods.length() - 1); resp->addHeader("ALLOW", methods);