View | Details | Raw Unified | Return to bug 41391
Collapse All | Expand All

(-)modules/metadata/mod_expires.c (-8 / +9 lines)
Lines 395-402 Link Here
395
                                 apr_table_t *t)
395
                                 apr_table_t *t)
396
{
396
{
397
    apr_time_t base;
397
    apr_time_t base;
398
    apr_time_t additional;
399
    apr_time_t expires;
398
    apr_time_t expires;
399
    apr_time_t max_age;
400
    int additional_sec;
400
    int additional_sec;
401
    char *timestr;
401
    char *timestr;
402
402
Lines 409-424 Link Here
409
            return DECLINED;
409
            return DECLINED;
410
        }
410
        }
411
        base = r->finfo.mtime;
411
        base = r->finfo.mtime;
412
        additional_sec = atoi(&code[1]);
413
        additional = apr_time_from_sec(additional_sec);
414
        break;
412
        break;
415
    case 'A':
413
    case 'A':
416
        /* there's been some discussion and it's possible that
414
        /* there's been some discussion and it's possible that
417
         * 'access time' will be stored in request structure
415
         * 'access time' will be stored in request structure
418
         */
416
         */
419
        base = r->request_time;
417
        base = r->request_time;
420
        additional_sec = atoi(&code[1]);
421
        additional = apr_time_from_sec(additional_sec);
422
        break;
418
        break;
423
    default:
419
    default:
424
        /* expecting the add_* routines to be case-hardened this
420
        /* expecting the add_* routines to be case-hardened this
Lines 428-438 Link Here
428
                    "internal error: bad expires code: %s", r->filename);
424
                    "internal error: bad expires code: %s", r->filename);
429
        return HTTP_INTERNAL_SERVER_ERROR;
425
        return HTTP_INTERNAL_SERVER_ERROR;
430
    }
426
    }
431
427
    additional_sec = atoi(&code[1]);
432
    expires = base + additional;
428
    /* Do not let max-age be negetive.
429
     */
430
    max_age = apr_time_sec(base - r->request_time) + additional_sec;
431
    if (max_age < 0) max_age = APR_INT64_MAX;
432
    expires = base + apr_time_from_sec(additional_sec);
433
    if (expires < 0) expires = APR_INT64_MAX;
433
    apr_table_mergen(t, "Cache-Control",
434
    apr_table_mergen(t, "Cache-Control",
434
                     apr_psprintf(r->pool, "max-age=%" APR_TIME_T_FMT,
435
                     apr_psprintf(r->pool, "max-age=%" APR_TIME_T_FMT,
435
                                  apr_time_sec(expires - r->request_time)));
436
                                  max_age));
436
    timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
437
    timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
437
    apr_rfc822_date(timestr, expires);
438
    apr_rfc822_date(timestr, expires);
438
    apr_table_setn(t, "Expires", timestr);
439
    apr_table_setn(t, "Expires", timestr);

Return to bug 41391