@@ -462,6 +462,7 @@ class Server {
462462 Server &Patch (const char *pattern, Handler handler);
463463 Server &Patch (const char *pattern, HandlerWithContentReader handler);
464464 Server &Delete (const char *pattern, Handler handler);
465+ Server &Delete (const char *pattern, HandlerWithContentReader handler);
465466 Server &Options (const char *pattern, Handler handler);
466467
467468 [[deprecated]] bool set_base_dir (const char *dir,
@@ -551,6 +552,7 @@ class Server {
551552 Handlers patch_handlers_;
552553 HandlersForContentReader patch_handlers_for_content_reader_;
553554 Handlers delete_handlers_;
555+ HandlersForContentReader delete_handlers_for_content_reader_;
554556 Handlers options_handlers_;
555557 Handler error_handler_;
556558 Logger logger_;
@@ -2515,7 +2517,7 @@ get_range_offset_and_length(const Request &req, const Response &res,
25152517
25162518inline bool expect_content (const Request &req) {
25172519 if (req.method == " POST" || req.method == " PUT" || req.method == " PATCH" ||
2518- req.method == " PRI" ) {
2520+ req.method == " PRI" || req. method == " DELETE " ) {
25192521 return true ;
25202522 }
25212523 // TODO: check if Content-Length is set
@@ -2968,6 +2970,13 @@ inline Server &Server::Delete(const char *pattern, Handler handler) {
29682970 return *this ;
29692971}
29702972
2973+ inline Server &Server::Delete (const char *pattern,
2974+ HandlerWithContentReader handler) {
2975+ delete_handlers_for_content_reader_.push_back (
2976+ std::make_pair (std::regex (pattern), handler));
2977+ return *this ;
2978+ }
2979+
29712980inline Server &Server::Options (const char *pattern, Handler handler) {
29722981 options_handlers_.push_back (std::make_pair (std::regex (pattern), handler));
29732982 return *this ;
@@ -3481,6 +3490,12 @@ inline bool Server::routing(Request &req, Response &res, Stream &strm) {
34813490 return true ;
34823491 }
34833492 }
3493+ else if (req.method == " DELETE" ) {
3494+ if (dispatch_request_for_content_reader (
3495+ req, res, reader, delete_handlers_for_content_reader_)) {
3496+ return true ;
3497+ }
3498+ }
34843499 }
34853500
34863501 // Read content into `req.body`
0 commit comments