Commit 84f6faf4 authored by Justin Erenkrantz's avatar Justin Erenkrantz
Browse files

Return the proper status and headers when serving a revalidated response.

* modules/cache/mod_cache.c
  (cache_save_filter): Load in the cached status and headers; send a flush
  rather than an EOS when the client request is conditional.
* modules/cache/mod_cache.h: Export ap_cache_accept_headers.
* modules/cache/cache_storage.c: Rename accept_headers to
  ap_cache_accept_headers.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@152680 13f79535-47bb-0310-9956-ffa450edef68
parent fe6e7c89
Loading
Loading
Loading
Loading
+2 −2
Changes for modules/cache/cache_storage.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ static int set_cookie_doo_doo(void *v, const char *key, const char *val)
    return 1;
}

static void accept_headers(cache_handle_t *h, request_rec *r)
CACHE_DECLARE(void) ap_cache_accept_headers(cache_handle_t *h, request_rec *r)
{
    apr_table_t *cookie_table;
    const char *v;
@@ -272,7 +272,7 @@ int cache_select_url(request_rec *r, char *url)
            }

            /* Okay, this response looks okay.  Merge in our stuff and go. */
            accept_headers(h, r);
            ap_cache_accept_headers(h, r);

            cache->handle = h;
            return OK;
+7 −1
Changes for modules/cache/mod_cache.c: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -532,6 +532,12 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
            /* Oh, hey.  It isn't that stale!  Yay! */
            cache->handle = cache->stale_handle;
            info = &cache->handle->cache_obj->info;
            /* Load in the saved status. */
            r->status = info->status;
            /* The cached response will override our err_headers_out. */
            apr_table_clear(r->err_headers_out);
            /* Merge in our headers. */
            ap_cache_accept_headers(cache->handle, r);
            rv = OK;
        }
        else {
@@ -665,7 +671,7 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
            /* FIXME: Should we now go and make sure it's really not
             * modified since what the user thought?
             */
            bkt = apr_bucket_eos_create(bb->bucket_alloc);
            bkt = apr_bucket_flush_create(bb->bucket_alloc);
            APR_BRIGADE_INSERT_TAIL(bb, bkt);
        }
        else {
+3 −0
Changes for modules/cache/mod_cache.h: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -240,6 +240,9 @@ CACHE_DECLARE(apr_time_t) ap_cache_current_age(cache_info *info, const apr_time_
 * @return 0 ==> cache object is stale, 1 ==> cache object is fresh
 */
CACHE_DECLARE(int) ap_cache_check_freshness(cache_handle_t *h, request_rec *r);

CACHE_DECLARE(void) ap_cache_accept_headers(cache_handle_t *h, request_rec *r);

CACHE_DECLARE(apr_time_t) ap_cache_hex2usec(const char *x);
CACHE_DECLARE(void) ap_cache_usec2hex(apr_time_t j, char *y);
CACHE_DECLARE(char *) generate_name(apr_pool_t *p, int dirlevels,