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

Function dav_method_search

modules/dav/main/mod_dav.c:1644–1695  ·  view source on GitHub ↗

handle the SEARCH method */

Source from the content-addressed store, hash-verified

1642
1643/* handle the SEARCH method */
1644static int dav_method_search(request_rec *r)
1645{
1646 const dav_hooks_search *search_hooks = DAV_GET_HOOKS_SEARCH(r);
1647 dav_resource *resource;
1648 dav_error *err;
1649 dav_response *multi_status;
1650
1651 /* If no search provider, decline the request */
1652 if (search_hooks == NULL)
1653 return DECLINED;
1654
1655 /* This method should only be called when the resource is not
1656 * visible to Apache. We will fetch the resource from the repository,
1657 * then create a subrequest for Apache to handle.
1658 */
1659 err = dav_get_resource(r, 1 /* label_allowed */, 0 /* use_checked_in */,
1660 &resource);
1661 if (err != NULL)
1662 return dav_handle_err(r, err, NULL);
1663
1664 if (!resource->exists) {
1665 /* Apache will supply a default error for this. */
1666 return HTTP_NOT_FOUND;
1667 }
1668
1669 /* set up the HTTP headers for the response */
1670 if ((err = (*resource->hooks->set_headers)(r, resource)) != NULL) {
1671 err = dav_push_error(r->pool, err->status, 0,
1672 "Unable to set up HTTP headers.",
1673 err);
1674 return dav_handle_err(r, err, NULL);
1675 }
1676
1677 if (r->header_only) {
1678 return DONE;
1679 }
1680
1681 /* okay... time to search the content */
1682 /* Let's validate XML and process walk function
1683 * in the hook function
1684 */
1685 if ((err = (*search_hooks->search_resource)(r, &multi_status)) != NULL) {
1686 /* ### add a higher-level description? */
1687 return dav_handle_err(r, err, NULL);
1688 }
1689
1690 /* We have results in multi_status */
1691 /* Should I pass namespace?? */
1692 dav_send_multistatus(r, HTTP_MULTI_STATUS, multi_status, NULL);
1693
1694 return DONE;
1695}
1696
1697
1698/* handle the OPTIONS method */

Callers 1

dav_handlerFunction · 0.85

Calls 4

dav_get_resourceFunction · 0.85
dav_handle_errFunction · 0.85
dav_push_errorFunction · 0.85
dav_send_multistatusFunction · 0.85

Tested by

no test coverage detected