mirror of
https://github.com/apache/httpd.git
synced 2025-08-10 02:02:49 +03:00
Add a new parameter to the quick_handler hook to instruct
quick handlers to optionally do a lookup rather than actually serve content. This is the first of several changes required fix several problems with how quick handlers work with subrequests. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94240 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
5
CHANGES
5
CHANGES
@@ -1,4 +1,9 @@
|
||||
Changes with Apache 2.0.35
|
||||
*) Add a new parameter to the quick_handler hook to instruct
|
||||
quick handlers to optionally do a lookup rather than actually
|
||||
serve content. This is the first of several changes required fix
|
||||
several problems with how quick handlers work with subrequests.
|
||||
[Bill Stoddard]
|
||||
|
||||
*) worker MPM: Get MaxRequestsPerChild to work again. [Jeff Trawick]
|
||||
|
||||
|
@@ -101,12 +101,13 @@
|
||||
* 20020306 (2.0.34-dev) bump for filter type renames.
|
||||
* 20020318 (2.0.34-dev) mod_dav's API for REPORT generation changed
|
||||
* 20020319 (2.0.34-dev) M_INVALID changed, plus new M_* methods for RFC 3253
|
||||
* 20020327 (2.0.35-dev) Add parameter to quick_handler hook
|
||||
*/
|
||||
|
||||
#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
|
||||
|
||||
#ifndef MODULE_MAGIC_NUMBER_MAJOR
|
||||
#define MODULE_MAGIC_NUMBER_MAJOR 20020319
|
||||
#define MODULE_MAGIC_NUMBER_MAJOR 20020327
|
||||
#endif
|
||||
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
|
||||
#define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR /* backward compat */
|
||||
|
@@ -1013,9 +1013,13 @@ AP_DECLARE_HOOK(int,handler,(request_rec *r))
|
||||
* is run before any other requests hooks are called (location_walk,
|
||||
* directory_walk, access checking, et. al.). This hook was added
|
||||
* to provide a quick way to serve content from a URI keyed cache.
|
||||
*
|
||||
* @param r The request_rec
|
||||
* @param lookup_uri Controls whether the caller actually wants content or not.
|
||||
* lookup is set when the quick_handler is called out of
|
||||
* ap_sub_req_lookup_uri()
|
||||
*/
|
||||
AP_DECLARE_HOOK(int,quick_handler,(request_rec *r))
|
||||
AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))
|
||||
|
||||
/**
|
||||
* Retrieve the optional functions for each module.
|
||||
|
@@ -82,7 +82,7 @@ APR_OPTIONAL_FN_TYPE(ap_cache_generate_key) *cache_generate_key;
|
||||
* oh well.
|
||||
*/
|
||||
|
||||
static int cache_url_handler(request_rec *r)
|
||||
static int cache_url_handler(request_rec *r, int lookup)
|
||||
{
|
||||
apr_status_t rv;
|
||||
const char *cc_in, *pragma, *auth;
|
||||
@@ -189,12 +189,13 @@ static int cache_url_handler(request_rec *r)
|
||||
|
||||
rv = cache_select_url(r, cache->types, url);
|
||||
if (DECLINED == rv) {
|
||||
if (!lookup) {
|
||||
/* no existing cache file */
|
||||
ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
|
||||
"cache: no cache - add cache_in filter and DECLINE");
|
||||
/* add cache_in filter to cache this request */
|
||||
ap_add_output_filter("CACHE_IN", NULL, r, r->connection);
|
||||
/* return DECLINED */
|
||||
}
|
||||
return DECLINED;
|
||||
}
|
||||
else if (OK == rv) {
|
||||
@@ -203,6 +204,9 @@ static int cache_url_handler(request_rec *r)
|
||||
apr_bucket_brigade *out;
|
||||
|
||||
/* fresh data available */
|
||||
if (lookup) {
|
||||
return OK;
|
||||
}
|
||||
ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
|
||||
"cache: fresh cache - add cache_out filter and "
|
||||
"handle request");
|
||||
@@ -235,6 +239,10 @@ static int cache_url_handler(request_rec *r)
|
||||
}
|
||||
else {
|
||||
/* stale data available */
|
||||
if (lookup) {
|
||||
return DECLINED;
|
||||
}
|
||||
|
||||
ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
|
||||
"cache: stale cache - test conditional");
|
||||
/* if conditional request */
|
||||
|
@@ -239,11 +239,29 @@ void ap_process_request(request_rec *r)
|
||||
{
|
||||
int access_status;
|
||||
|
||||
/* Give quick handlers a shot at serving the request on the fast
|
||||
* path, bypassing all of the other Apache hooks.
|
||||
*
|
||||
* This hook was added to enable serving files out of a URI keyed
|
||||
* content cache ( e.g., Mike Abbott's Quick Shortcut Cache,
|
||||
* described here: http://oss.sgi.com/projects/apache/mod_qsc.html )
|
||||
*
|
||||
* It may have other uses as well, such as routing requests directly to
|
||||
* content handlers that have the ability to grok HTTP and do their
|
||||
* own access checking, etc (e.g. servlet engines).
|
||||
*
|
||||
* Use this hook with extreme care and only if you know what you are
|
||||
* doing.
|
||||
*/
|
||||
access_status = ap_run_quick_handler(r, 0); /* Not a look-up request */
|
||||
if (access_status == DECLINED) {
|
||||
access_status = ap_process_request_internal(r);
|
||||
if (access_status == OK) {
|
||||
access_status = ap_invoke_handler(r);
|
||||
}
|
||||
else if (access_status == DONE) {
|
||||
}
|
||||
|
||||
if (access_status == DONE) {
|
||||
/* e.g., something not in storage like TRACE */
|
||||
access_status = OK;
|
||||
}
|
||||
|
@@ -193,8 +193,8 @@ AP_IMPLEMENT_HOOK_VOID(child_init,
|
||||
AP_IMPLEMENT_HOOK_RUN_FIRST(int, handler, (request_rec *r),
|
||||
(r), DECLINED)
|
||||
|
||||
AP_IMPLEMENT_HOOK_RUN_FIRST(int, quick_handler, (request_rec *r),
|
||||
(r), DECLINED)
|
||||
AP_IMPLEMENT_HOOK_RUN_FIRST(int, quick_handler, (request_rec *r, int lookup),
|
||||
(r, lookup), DECLINED)
|
||||
|
||||
AP_IMPLEMENT_HOOK_VOID(optional_fn_retrieve, (void), ())
|
||||
|
||||
|
@@ -145,36 +145,6 @@ AP_DECLARE(int) ap_process_request_internal(request_rec *r)
|
||||
int file_req = (r->main && r->filename);
|
||||
int access_status;
|
||||
|
||||
/* Give quick handlers a shot at serving the request on the fast
|
||||
* path, bypassing all of the other Apache hooks. Bypass the call
|
||||
* for dirent subrequests (any other cases to bypass?)
|
||||
*
|
||||
* This hook was added to enable serving files out of a URI keyed
|
||||
* content cache ( e.g., Mike Abbott's Quick Shortcut Cache,
|
||||
* described here: http://oss.sgi.com/projects/apache/mod_qsc.html )
|
||||
*
|
||||
* It may have other uses as well, such as routing requests directly to
|
||||
* content handlers that have the ability to grok HTTP and do their
|
||||
* own access checking, etc (e.g. servlet engines).
|
||||
*
|
||||
* Use this hook with extreme care and only if you know what you are
|
||||
* doing. This hook is available to (non dirent) subrequests.
|
||||
*/
|
||||
if (!(r->main && r->filename && r->finfo.filetype)) {
|
||||
/* TODO?: Add a field to the request_rec explicitly identifying
|
||||
* the type of subrequest?
|
||||
*/
|
||||
access_status = ap_run_quick_handler(r);
|
||||
if (access_status != DECLINED) {
|
||||
if (access_status == OK) {
|
||||
return DONE;
|
||||
}
|
||||
else {
|
||||
return access_status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Ignore embedded %2F's in path for proxy requests */
|
||||
if (!r->proxyreq && r->parsed_uri.path) {
|
||||
access_status = ap_unescape_url(r->parsed_uri.path);
|
||||
@@ -1657,10 +1627,17 @@ AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method,
|
||||
udir = ap_escape_uri(rnew->pool, udir); /* re-escape it */
|
||||
ap_parse_uri(rnew, ap_make_full_path(rnew->pool, udir, new_file));
|
||||
}
|
||||
/* lookup_uri
|
||||
* If the content can be served by the quick_handler, we can
|
||||
* safely bypass request_internal processing.
|
||||
*/
|
||||
res = ap_run_quick_handler(rnew, 1);
|
||||
|
||||
if (res != OK) {
|
||||
if ((res = ap_process_request_internal(rnew))) {
|
||||
rnew->status = res;
|
||||
}
|
||||
}
|
||||
|
||||
return rnew;
|
||||
}
|
||||
@@ -1879,9 +1856,16 @@ AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file,
|
||||
|
||||
AP_DECLARE(int) ap_run_sub_req(request_rec *r)
|
||||
{
|
||||
int retval;
|
||||
|
||||
int retval = DECLINED;
|
||||
/* Run the quick handler if the subrequest is not a dirent or file
|
||||
* subrequest
|
||||
*/
|
||||
if (!(r->filename && r->finfo.filetype)) {
|
||||
retval = ap_run_quick_handler(r, 0);
|
||||
}
|
||||
if (retval != OK) {
|
||||
retval = ap_invoke_handler(r);
|
||||
}
|
||||
ap_finalize_sub_req_protocol(r);
|
||||
return retval;
|
||||
}
|
||||
|
Reference in New Issue
Block a user