@@ -462,6 +462,7 @@ class Server {
462
462
Server &Patch (const char *pattern, Handler handler);
463
463
Server &Patch (const char *pattern, HandlerWithContentReader handler);
464
464
Server &Delete (const char *pattern, Handler handler);
465
+ Server &Delete (const char *pattern, HandlerWithContentReader handler);
465
466
Server &Options (const char *pattern, Handler handler);
466
467
467
468
[[deprecated]] bool set_base_dir (const char *dir,
@@ -551,6 +552,7 @@ class Server {
551
552
Handlers patch_handlers_;
552
553
HandlersForContentReader patch_handlers_for_content_reader_;
553
554
Handlers delete_handlers_;
555
+ HandlersForContentReader delete_handlers_for_content_reader_;
554
556
Handlers options_handlers_;
555
557
Handler error_handler_;
556
558
Logger logger_;
@@ -2515,7 +2517,7 @@ get_range_offset_and_length(const Request &req, const Response &res,
2515
2517
2516
2518
inline bool expect_content (const Request &req) {
2517
2519
if (req.method == " POST" || req.method == " PUT" || req.method == " PATCH" ||
2518
- req.method == " PRI" ) {
2520
+ req.method == " PRI" || req. method == " DELETE " ) {
2519
2521
return true ;
2520
2522
}
2521
2523
// TODO: check if Content-Length is set
@@ -2968,6 +2970,13 @@ inline Server &Server::Delete(const char *pattern, Handler handler) {
2968
2970
return *this ;
2969
2971
}
2970
2972
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
+
2971
2980
inline Server &Server::Options (const char *pattern, Handler handler) {
2972
2981
options_handlers_.push_back (std::make_pair (std::regex (pattern), handler));
2973
2982
return *this ;
@@ -3481,6 +3490,12 @@ inline bool Server::routing(Request &req, Response &res, Stream &strm) {
3481
3490
return true ;
3482
3491
}
3483
3492
}
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
+ }
3484
3499
}
3485
3500
3486
3501
// Read content into `req.body`
0 commit comments