~ubuntu-branches/ubuntu/lucid/nginx/lucid-updates

« back to all changes in this revision

Viewing changes to src/http/modules/ngx_http_headers_filter_module.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2008-12-01 20:11:53 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081201201153-q0ap33bcphfxriy3
Tags: 0.6.34-1ubuntu1
* Merge from debian unstable, remaining changes: (LP: #303916)
  + debian/control:
    - Add Depend on lsb >= 3.2-14, which has the status_of_proc() function.
  + debian/init.d:
    - Add sourcing to '. /lib/lsb/init-functions'
    - Add the 'status' action
  + Fixed FTBFS by properly defining IOV_MAX to its Linux equivelent.
  + Added dpatch based patch system

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#define NGX_HTTP_EXPIRES_MAX       2
37
37
#define NGX_HTTP_EXPIRES_ACCESS    3
38
38
#define NGX_HTTP_EXPIRES_MODIFIED  4
 
39
#define NGX_HTTP_EXPIRES_DAILY     5
39
40
 
40
41
 
41
42
typedef struct {
187
188
ngx_http_set_expires(ngx_http_request_t *r, ngx_http_headers_conf_t *conf)
188
189
{
189
190
    size_t            len;
190
 
    time_t            since;
 
191
    time_t            now, expires_time, max_age;
191
192
    ngx_uint_t        i;
192
193
    ngx_table_elt_t  *expires, *cc, **ccp;
193
194
 
279
280
        return NGX_OK;
280
281
    }
281
282
 
 
283
    now = ngx_time();
 
284
 
282
285
    if (conf->expires == NGX_HTTP_EXPIRES_ACCESS
283
286
        || r->headers_out.last_modified_time == -1)
284
287
    {
285
 
        since = ngx_time();
 
288
        expires_time = now + conf->expires_time;
 
289
        max_age = conf->expires_time;
 
290
 
 
291
    } else if (conf->expires == NGX_HTTP_EXPIRES_DAILY) {
 
292
        expires_time = ngx_next_time(conf->expires_time);
 
293
        max_age = expires_time - now;
286
294
 
287
295
    } else {
288
 
        since = r->headers_out.last_modified_time;
 
296
        expires_time = r->headers_out.last_modified_time + conf->expires_time;
 
297
        max_age = expires_time - now;
289
298
    }
290
299
 
291
 
    ngx_http_time(expires->value.data, since + conf->expires_time);
 
300
    ngx_http_time(expires->value.data, expires_time);
292
301
 
293
302
    if (conf->expires_time < 0) {
294
303
        cc->value.len = sizeof("no-cache") - 1;
303
312
        return NGX_ERROR;
304
313
    }
305
314
 
306
 
    cc->value.len = ngx_sprintf(cc->value.data, "max-age=%T",
307
 
                                since + conf->expires_time - ngx_time())
 
315
    cc->value.len = ngx_sprintf(cc->value.data, "max-age=%T", max_age)
308
316
                    - cc->value.data;
309
317
 
310
318
    return NGX_OK;
514
522
        n = 2;
515
523
    }
516
524
 
517
 
    if (value[n].data[0] == '+') {
 
525
    if (value[n].data[0] == '@') {
 
526
        value[n].data++;
 
527
        value[n].len--;
 
528
        minus = 0;
 
529
 
 
530
        if (hcf->expires == NGX_HTTP_EXPIRES_MODIFIED) {
 
531
            return "daily time can not be used with \"modified\" parameter";
 
532
        }
 
533
 
 
534
        hcf->expires = NGX_HTTP_EXPIRES_DAILY;
 
535
 
 
536
    } else if (value[n].data[0] == '+') {
518
537
        value[n].data++;
519
538
        value[n].len--;
520
539
        minus = 0;
534
553
        return "invalid value";
535
554
    }
536
555
 
 
556
    if (hcf->expires == NGX_HTTP_EXPIRES_DAILY
 
557
        && hcf->expires_time > 24 * 60 * 60)
 
558
    {
 
559
        return "daily time value must be less than 24 hours";
 
560
    }
 
561
 
537
562
    if (hcf->expires_time == NGX_PARSE_LARGE_TIME) {
538
563
        return "value must be less than 68 years";
539
564
    }