This patch gets mod_dav to register its methods dynamically.
Instead of relying on the fact that a method isn't registered
and comparing method strings, it now registers and compares
method numbers.
Sander
Index: modules/dav/main/mod_dav.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/dav/main/mod_dav.c,v
retrieving revision 1.65
diff -u -r1.65 mod_dav.c
--- modules/dav/main/mod_dav.c 2001/11/23 16:35:21 1.65
+++ modules/dav/main/mod_dav.c 2001/12/22 17:51:52
@@ -132,12 +132,51 @@
/* forward-declare for use in configuration lookup */
extern module DAV_DECLARE_DATA dav_module;
+/* DAV methods */
+#define DAV_M_VERSION_CONTROL 0
+#define DAV_M_CHECKOUT 1
+#define DAV_M_UNCHECKOUT 2
+#define DAV_M_CHECKIN 3
+#define DAV_M_UPDATE 4
+#define DAV_M_LABEL 5
+#define DAV_M_REPORT 6
+#define DAV_M_MKWORKSPACE 7
+#define DAV_M_MKACTIVITY 8
+#define DAV_M_BASELINE_CONTROL 9
+#define DAV_M_MERGE 10
+#define DAV_M_BIND 11
+
+static int dav_methods[12];
+
+static APR_INLINE void dav_register_method(apr_pool_t *p, int method_index,
+ const char *method)
+{
+ dav_methods[method_index] = ap_method_number_of(method);
+ if (dav_methods[method_index] == M_INVALID)
+ dav_methods[method_index] = ap_method_register(p, method);
+}
+
static int dav_init_handler(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp,
server_rec *s)
{
/* DBG0("dav_init_handler"); */
+ /* Register DAV methods */
+ dav_register_method(p, DAV_M_VERSION_CONTROL, "VERSION-CONTROL");
+ dav_register_method(p, DAV_M_CHECKOUT, "CHECKOUT");
+ dav_register_method(p, DAV_M_UNCHECKOUT, "UNCHECKOUT");
+ dav_register_method(p, DAV_M_CHECKIN, "CHECKIN");
+ dav_register_method(p, DAV_M_UPDATE, "UPDATE");
+ dav_register_method(p, DAV_M_LABEL, "LABEL");
+ dav_register_method(p, DAV_M_REPORT, "REPORT");
+ dav_register_method(p, DAV_M_MKWORKSPACE, "MKWORKSPACE");
+ dav_register_method(p, DAV_M_MKACTIVITY, "MKACTIVITY");
+ dav_register_method(p, DAV_M_BASELINE_CONTROL, "BASELINE-CONTROL");
+ dav_register_method(p, DAV_M_MERGE, "MERGE");
+ dav_register_method(p, DAV_M_BIND, "BIND");
+
ap_add_version_component(p, "DAV/2");
+
return OK;
}
@@ -4478,61 +4517,52 @@
if (r->method_number == M_UNLOCK) {
return dav_method_unlock(r);
}
-
- /*
- * NOTE: When Apache moves creates defines for the add'l DAV methods,
- * then it will no longer use M_INVALID. This code must be
- * updated each time Apache adds method defines.
- */
- if (r->method_number != M_INVALID) {
- return DECLINED;
- }
- if (!strcmp(r->method, "VERSION-CONTROL")) {
+ if (r->method_number == dav_methods[DAV_M_VERSION_CONTROL]) {
return dav_method_vsn_control(r);
}
- if (!strcmp(r->method, "CHECKOUT")) {
+ if (r->method_number == dav_methods[DAV_M_CHECKOUT]) {
return dav_method_checkout(r);
}
- if (!strcmp(r->method, "UNCHECKOUT")) {
+ if (r->method_number == dav_methods[DAV_M_UNCHECKOUT]) {
return dav_method_uncheckout(r);
}
- if (!strcmp(r->method, "CHECKIN")) {
+ if (r->method_number == dav_methods[DAV_M_CHECKIN]) {
return dav_method_checkin(r);
}
- if (!strcmp(r->method, "UPDATE")) {
+ if (r->method_number == dav_methods[DAV_M_UPDATE]) {
return dav_method_update(r);
}
- if (!strcmp(r->method, "LABEL")) {
+ if (r->method_number == dav_methods[DAV_M_LABEL]) {
return dav_method_label(r);
}
- if (!strcmp(r->method, "REPORT")) {
+ if (r->method_number == dav_methods[DAV_M_REPORT]) {
return dav_method_report(r);
}
- if (!strcmp(r->method, "MKWORKSPACE")) {
+ if (r->method_number == dav_methods[DAV_M_MKWORKSPACE]) {
return dav_method_make_workspace(r);
}
- if (!strcmp(r->method, "MKACTIVITY")) {
+ if (r->method_number == dav_methods[DAV_M_MKACTIVITY]) {
return dav_method_make_activity(r);
}
- if (!strcmp(r->method, "BASELINE-CONTROL")) {
+ if (r->method_number == dav_methods[DAV_M_BASELINE_CONTROL]) {
return dav_method_baseline_control(r);
}
- if (!strcmp(r->method, "MERGE")) {
+ if (r->method_number == dav_methods[DAV_M_MERGE]) {
return dav_method_merge(r);
}
- if (!strcmp(r->method, "BIND")) {
+ if (r->method_number == dav_methods[DAV_M_BIND]) {
return dav_method_bind(r);
}