diff --git a/src/httpd.c b/src/httpd.c index 3a3852e8..5b3ec74b 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -880,6 +880,7 @@ httpd_request_parse(struct evhttp_request *req, struct httpd_uri_parsed *uri_par struct httpd_request *hreq; struct evhttp_connection *evcon; struct evkeyvalq *headers; + int req_method; int i; int ret; @@ -889,6 +890,7 @@ httpd_request_parse(struct evhttp_request *req, struct httpd_uri_parsed *uri_par hreq->req = req; hreq->uri_parsed = uri_parsed; hreq->query = &(uri_parsed->ev_query); + req_method = 0; if (req) { @@ -900,6 +902,8 @@ httpd_request_parse(struct evhttp_request *req, struct httpd_uri_parsed *uri_par evhttp_connection_get_peer(evcon, &hreq->peer_address, &hreq->peer_port); else DPRINTF(E_LOG, L_HTTPD, "Connection to client lost or missing\n"); + + req_method = evhttp_request_get_command(req); } if (user_agent) @@ -908,6 +912,10 @@ httpd_request_parse(struct evhttp_request *req, struct httpd_uri_parsed *uri_par // Find a handler for the path for (i = 0; uri_map[i].handler; i++) { + // Check if handler supports the current http request method + if (uri_map[i].method && req_method && !(req_method & uri_map[i].method)) + continue; + ret = regexec(&uri_map[i].preg, uri_parsed->path, 0, NULL, 0); if (ret == 0) { diff --git a/src/httpd.h b/src/httpd.h index 74ddef15..bf071d27 100644 --- a/src/httpd.h +++ b/src/httpd.h @@ -69,6 +69,7 @@ struct httpd_request { */ struct httpd_uri_map { + int method; char *regexp; int (*handler)(struct httpd_request *hreq); regex_t preg;