diff options
author | manu <manu@unknown> | 2023-02-13 17:48:35 +0100 |
---|---|---|
committer | manu <manu@unknown> | 2023-02-13 17:48:35 +0100 |
commit | bed50350e49fd6bde43458c9d71db5853c8abd88 (patch) | |
tree | 1efd61b576b4b1ef114a319ed19ffaa3cef33ab1 /modules/dav/main/mod_dav.c | |
parent | * Optimize code: We know that we already have a valid encoding string, (diff) | |
download | apache2-bed50350e49fd6bde43458c9d71db5853c8abd88.tar.xz apache2-bed50350e49fd6bde43458c9d71db5853c8abd88.zip |
Add MS-WDV support
MS-WDV specification:
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wdv
The changes introduces the DAVMSext directive, which is used to
enable MS-WDV: DAVMSext +WDV
dav_get_timeout_string() is introduced as a variant of dav_get_timeout().
The former parses a string, the later parse the Timeout HTTP header.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1907608 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/dav/main/mod_dav.c')
-rw-r--r-- | modules/dav/main/mod_dav.c | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/modules/dav/main/mod_dav.c b/modules/dav/main/mod_dav.c index ea87317c3f..51687203cc 100644 --- a/modules/dav/main/mod_dav.c +++ b/modules/dav/main/mod_dav.c @@ -76,6 +76,12 @@ enum { DAV_ENABLED_ON }; +typedef enum { + DAV_MSEXT_NONE = 0, + DAV_MSEXT_WDV = 1, + DAV_MSEXT_ALL = 1, +} dav_msext_opts; + /* per-dir configuration */ typedef struct { const char *provider_name; @@ -84,7 +90,7 @@ typedef struct { int locktimeout; int allow_depthinfinity; int allow_lockdiscovery; - + dav_msext_opts msext_opts; } dav_dir_conf; /* per-server configuration */ @@ -108,6 +114,7 @@ enum { }; static int dav_methods[DAV_M_LAST]; +static const char *dav_cmd_davmsext(cmd_parms *, void *, const char *); static int dav_init_handler(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) @@ -206,6 +213,8 @@ static void *dav_merge_dir_config(apr_pool_t *p, void *base, void *overrides) allow_depthinfinity); newconf->allow_lockdiscovery = DAV_INHERIT_VALUE(parent, child, allow_lockdiscovery); + newconf->msext_opts = DAV_INHERIT_VALUE(parent, child, + msext_opts); return newconf; } @@ -319,6 +328,33 @@ static const char *dav_cmd_davlockdiscovery(cmd_parms *cmd, void *config, } /* + * Command handler for the DAVmsExt directive, which is RAW + */ +static const char *dav_cmd_davmsext(cmd_parms *cmd, void *config, const char *w) +{ + dav_dir_conf *conf = (dav_dir_conf *)config; + + if (!ap_cstr_casecmp(w, "None")) + conf->msext_opts = DAV_MSEXT_NONE; + else if (!ap_cstr_casecmp(w, "Off")) + conf->msext_opts = DAV_MSEXT_NONE; + else if (!ap_cstr_casecmp(w, "+WDV")) + conf->msext_opts |= DAV_MSEXT_WDV; + else if (!ap_cstr_casecmp(w, "WDV")) + conf->msext_opts |= DAV_MSEXT_WDV; + else if (!ap_cstr_casecmp(w, "-WDV")) + conf->msext_opts &= ~DAV_MSEXT_WDV; + else if (!ap_cstr_casecmp(w, "All")) + conf->msext_opts = DAV_MSEXT_ALL; + else if (!ap_cstr_casecmp(w, "On")) + conf->msext_opts = DAV_MSEXT_ALL; + else + return "DAVMSext values can be None | [+|-]WDV | All"; + + return NULL; +} + +/* * Command handler for DAVMinTimeout directive, which is TAKE1 */ static const char *dav_cmd_davmintimeout(cmd_parms *cmd, void *config, @@ -964,6 +1000,7 @@ static int dav_method_post(request_rec *r) /* handle the PUT method */ static int dav_method_put(request_rec *r) { + dav_dir_conf *conf; dav_resource *resource; int resource_state; dav_auto_version_info av_info; @@ -1167,6 +1204,11 @@ static int dav_method_put(request_rec *r) dav_log_err(r, err2, APLOG_WARNING); } + /* This performs MS-WDV PROPPATCH combined with PUT */ + conf = ap_get_module_config(r->per_dir_config, &dav_module); + if (conf->msext_opts & DAV_MSEXT_WDV) + (void)dav_mswdv_postprocessing(r); + /* ### place the Content-Type and Content-Language into the propdb */ if (locks_hooks != NULL) { @@ -4971,6 +5013,15 @@ static int dav_method_bind(request_rec *r) */ static int dav_handler(request_rec *r) { + dav_dir_conf *conf; + int ret; + + conf = ap_get_module_config(r->per_dir_config, &dav_module); + if (conf->msext_opts & DAV_MSEXT_WDV) { + if ((ret = dav_mswdv_preprocessing(r)) != OK) + return ret; + } + if (strcmp(r->handler, DAV_HANDLER_NAME) != 0) return DECLINED; @@ -4978,7 +5029,7 @@ static int dav_handler(request_rec *r) * be more destructive than the user intended. */ if (r->parsed_uri.fragment != NULL) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00622) - "buggy client used un-escaped hash in Request-URI"); + "buggy client used un-escaped hash in Request-URI %s in method %d", r->unparsed_uri, r->method_number); return dav_error_response(r, HTTP_BAD_REQUEST, "The request was invalid: the URI included " "an un-escaped hash character"); @@ -5204,6 +5255,8 @@ static int dav_fixups(request_rec *r) return DECLINED; } + + static void register_hooks(apr_pool_t *p) { ap_hook_handler(dav_handler, NULL, NULL, APR_HOOK_MIDDLE); @@ -5219,6 +5272,11 @@ static void register_hooks(apr_pool_t *p) dav_hook_gather_reports(dav_core_gather_reports, NULL, NULL, APR_HOOK_LAST); + ap_register_output_filter("DAV_MSWDV_OUT", dav_mswdv_output, NULL, + AP_FTYPE_RESOURCE); + ap_register_input_filter("DAV_MSWDV_IN", dav_mswdv_input, NULL, + AP_FTYPE_RESOURCE); + dav_core_register_uris(p); } @@ -5248,6 +5306,11 @@ static const command_rec dav_cmds[] = ACCESS_CONF|RSRC_CONF, "allow lock discovery by PROPFIND requests"), + /* per directory/location, or per server */ + AP_INIT_ITERATE("DAVMSext", dav_cmd_davmsext, NULL, + ACCESS_CONF|RSRC_CONF, + "Enable MS-WDV extensions"), + { NULL } }; |