Changeset 4547:2577c27cbffd in nginx


Ignore:
Timestamp:
03/21/12 06:19:11 (8 years ago)
Author:
Ruslan Ermilov <ru@…>
Branch:
default
Phase:
public
Convert:
svn:c3fe7df1-7212-e011-8a91-001109144009/trunk@4548
Message:

Minor ngx_http_headers_filter_module.c code cleanup.

  • Removed "hash" element from ngx_http_header_val_t which was always 1.
  • Replaced NGX_HTTP_EXPIRES_* with ngx_http_expires_t enum type.
  • Added prototype for ngx_http_add_header()
  • Simplified ngx_http_set_last_modified().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/http/modules/ngx_http_headers_filter_module.c

    r4491 r4547  
    2626struct ngx_http_header_val_s {
    2727    ngx_http_complex_value_t   value;
    28     ngx_uint_t                 hash;
    2928    ngx_str_t                  key;
    3029    ngx_http_set_header_pt     handler;
     
    3332
    3433
    35 #define NGX_HTTP_EXPIRES_OFF       0
    36 #define NGX_HTTP_EXPIRES_EPOCH     1
    37 #define NGX_HTTP_EXPIRES_MAX       2
    38 #define NGX_HTTP_EXPIRES_ACCESS    3
    39 #define NGX_HTTP_EXPIRES_MODIFIED  4
    40 #define NGX_HTTP_EXPIRES_DAILY     5
     34typedef enum {
     35    NGX_HTTP_EXPIRES_OFF,
     36    NGX_HTTP_EXPIRES_EPOCH,
     37    NGX_HTTP_EXPIRES_MAX,
     38    NGX_HTTP_EXPIRES_ACCESS,
     39    NGX_HTTP_EXPIRES_MODIFIED,
     40    NGX_HTTP_EXPIRES_DAILY,
     41    NGX_HTTP_EXPIRES_UNSET
     42} ngx_http_expires_t;
    4143
    4244
    4345typedef struct {
    44     ngx_uint_t               expires;
     46    ngx_http_expires_t       expires;
    4547    time_t                   expires_time;
    4648    ngx_array_t             *headers;
     
    5153    ngx_http_headers_conf_t *conf);
    5254static ngx_int_t ngx_http_add_cache_control(ngx_http_request_t *r,
     55    ngx_http_header_val_t *hv, ngx_str_t *value);
     56static ngx_int_t ngx_http_add_header(ngx_http_request_t *r,
    5357    ngx_http_header_val_t *hv, ngx_str_t *value);
    5458static ngx_int_t ngx_http_set_last_modified(ngx_http_request_t *r,
     
    314318        }
    315319
    316         h->hash = hv->hash;
     320        h->hash = 1;
    317321        h->key = hv->key;
    318322        h->value = *value;
     
    367371    ngx_table_elt_t  *h, **old;
    368372
    369     if (hv->offset) {
    370         old = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset);
    371 
    372     } else {
    373         old = NULL;
    374     }
     373    old = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset);
    375374
    376375    r->headers_out.last_modified_time = -1;
    377376
    378     if (old == NULL || *old == NULL) {
     377    if (*old == NULL) {
    379378
    380379        if (value->len == 0) {
     
    396395    }
    397396
    398     h->hash = hv->hash;
     397    h->hash = 1;
    399398    h->key = hv->key;
    400399    h->value = *value;
     
    421420     */
    422421
    423     conf->expires = NGX_CONF_UNSET_UINT;
     422    conf->expires = NGX_HTTP_EXPIRES_UNSET;
    424423
    425424    return conf;
     
    433432    ngx_http_headers_conf_t *conf = child;
    434433
    435     if (conf->expires == NGX_CONF_UNSET_UINT) {
     434    if (conf->expires == NGX_HTTP_EXPIRES_UNSET) {
    436435        conf->expires = prev->expires;
    437436        conf->expires_time = prev->expires_time;
    438437
    439         if (conf->expires == NGX_CONF_UNSET_UINT) {
     438        if (conf->expires == NGX_HTTP_EXPIRES_UNSET) {
    440439            conf->expires = NGX_HTTP_EXPIRES_OFF;
    441440        }
     
    468467    ngx_str_t   *value;
    469468
    470     if (hcf->expires != NGX_CONF_UNSET_UINT) {
     469    if (hcf->expires != NGX_HTTP_EXPIRES_UNSET) {
    471470        return "is duplicate";
    472471    }
     
    577576    }
    578577
    579     hv->hash = 1;
    580578    hv->key = value[1];
    581579    hv->handler = ngx_http_add_header;
Note: See TracChangeset for help on using the changeset viewer.