MCPcopy Create free account
hub / github.com/apache/httpd / dav_gen_supported_methods

Function dav_gen_supported_methods

modules/dav/main/mod_dav.c:1390–1453  ·  view source on GitHub ↗

generate DAV:supported-method-set OPTIONS response */

Source from the content-addressed store, hash-verified

1388
1389/* generate DAV:supported-method-set OPTIONS response */
1390static dav_error *dav_gen_supported_methods(request_rec *r,
1391 const apr_xml_elem *elem,
1392 const apr_table_t *methods,
1393 apr_text_header *body)
1394{
1395 const apr_array_header_t *arr;
1396 const apr_table_entry_t *elts;
1397 apr_xml_elem *child;
1398 apr_xml_attr *attr;
1399 char *s;
1400 int i;
1401
1402 apr_text_append(r->pool, body, "<D:supported-method-set>" DEBUG_CR);
1403
1404 if (elem->first_child == NULL) {
1405 /* show all supported methods */
1406 arr = apr_table_elts(methods);
1407 elts = (const apr_table_entry_t *)arr->elts;
1408
1409 for (i = 0; i < arr->nelts; ++i) {
1410 if (elts[i].key == NULL)
1411 continue;
1412
1413 s = apr_pstrcat(r->pool,
1414 "<D:supported-method D:name=\"",
1415 elts[i].key,
1416 "\"/>" DEBUG_CR, NULL);
1417 apr_text_append(r->pool, body, s);
1418 }
1419 }
1420 else {
1421 /* check for support of specific methods */
1422 for (child = elem->first_child; child != NULL; child = child->next) {
1423 if (child->ns == APR_XML_NS_DAV_ID
1424 && strcmp(child->name, "supported-method") == 0) {
1425 const char *name = NULL;
1426
1427 /* go through attributes to find method name */
1428 for (attr = child->attr; attr != NULL; attr = attr->next) {
1429 if (attr->ns == APR_XML_NS_DAV_ID
1430 && strcmp(attr->name, "name") == 0)
1431 name = attr->value;
1432 }
1433
1434 if (name == NULL) {
1435 return dav_new_error(r->pool, HTTP_BAD_REQUEST, 0, 0,
1436 "A DAV:supported-method element "
1437 "does not have a \"name\" attribute");
1438 }
1439
1440 /* see if method is supported */
1441 if (apr_table_get(methods, name) != NULL) {
1442 s = apr_pstrcat(r->pool,
1443 "<D:supported-method D:name=\"",
1444 name, "\"/>" DEBUG_CR, NULL);
1445 apr_text_append(r->pool, body, s);
1446 }
1447 }

Callers 1

dav_method_optionsFunction · 0.85

Calls 1

dav_new_errorFunction · 0.85

Tested by

no test coverage detected