Map to Storage (2.0)
int module_map_to_storage(request_rec *r)
This function allows
modules
to set the request_rec
’s
per_dir_config
according to their own view of the
world, if desired. It is also used to respond to contextless requests
(such as TRACE
). It should return
DONE
or an HTTP
return code if
a contextless request was fulfilled, OK
if the
module mapped it, or DECLINED
if not. The core
will handle this by doing a standard directory walk on the filename
if no other module does. See Example 21-15.
Example 21-15. http_protocol.c
AP_DECLARE_NONSTD(int) ap_send_http_trace(request_rec *r) { int rv; apr_bucket_brigade *b; header_struct h; if (r->method_number != M_TRACE) { return DECLINED; } /* Get the original request */ while (r->prev) { r = r->prev; } if ((rv = ap_setup_client_block(r, REQUEST_NO_BODY))) { return rv; } ap_set_content_type(r, "message/http"); /* Now we recreate the request, and echo it back */ b = apr_brigade_create(r->pool, r->connection->bucket_alloc); apr_brigade_putstrs(b, NULL, NULL, r->the_request, CRLF, NULL); h.pool = r->pool; h.bb = b; apr_table_do((int (*) (void *, const char *, const char *)) form_header_field, (void *) &h, r->headers_in, NULL); apr_brigade_puts(b, NULL, NULL, CRLF); ap_pass_brigade(r->output_filters, b); return DONE; }
This is the code that handles the TRACE
method.
Also, the following is from mod_proxy.c:
static int proxy_map_location(request_rec *r) { int access_status; if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0) return DECLINED; /* Don't let the core or mod_http map_to_storage hooks handle this, * We don't need directory/file_walk, and we want to TRACE on our own. */ if ((access_status = proxy_walk(r))) { ap_die(access_status, r); return access_status; } return OK; }