From 001a3da2cd9ef2c5d15f122a199a1694e912d89d Mon Sep 17 00:00:00 2001 From: Ken Coar Date: Fri, 11 Aug 2000 23:45:57 +0000 Subject: [PATCH] More prototypical API support for arbitrary extension HTTP methods. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86054 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_protocol.h | 9 +++++++++ modules/http/http_protocol.c | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/http_protocol.h b/include/http_protocol.h index 629ca448e6..7eee6329f3 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -470,6 +470,15 @@ CORE_EXPORT(void) ap_parse_uri(request_rec *r, const char *uri); */ API_EXPORT(int) ap_method_number_of(const char *method); +/** + * Get the method name associated with the given internal method + * number. Returns NULL if not recognized. + * @param methnum An integer value corresponding to an internal method number + * @return The name corresponding to the method number + * @deffunc const char *ap_method_name_of(int methnum) + */ +API_EXPORT(const char *) ap_method_name_of(int methnum); + /* Hooks */ /* * post_read_request --- run right after read_request or internal_redirect, diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 5adf6e7ede..3d206e24c0 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -809,6 +809,33 @@ API_EXPORT(int) ap_method_number_of(const char *method) return M_INVALID; } +API_EXPORT(const char *) ap_method_name_of(int methnum) { + static const char *AP_HTTP_METHODS[] = { + [M_GET] = "GET", + [M_PUT] = "PUT", + [M_POST] = "POST", + [M_DELETE] = "DELETE", + [M_CONNECT] = "CONNECT", + [M_OPTIONS] = "OPTIONS", + [M_TRACE] = "TRACE", + [M_PATCH] = "PATCH", + [M_PROPFIND] = "PROPFIND", + [M_PROPPATCH] = "PROPPATCH", + [M_MKCOL] = "MKCOL", + [M_COPY] = "COPY", + [M_MOVE] = "MOVE", + [M_LOCK] = "LOCK", + [M_UNLOCK] = "UNLOCK", + [M_INVALID] = NULL + }; + + + if ((methnum == M_INVALID) || (methnum >= METHODS)) { + return NULL; + } + return AP_HTTP_METHODS[methnum]; +} + /* Get a line of protocol input, including any continuation lines * caused by MIME folding (or broken clients) if fold != 0, and place it * in the buffer s, of size n bytes, without the ending newline. -- 2.50.1