~ubuntu-branches/debian/squeeze/nginx/squeeze

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella
  • Date: 2009-05-31 18:38:56 UTC
  • mfrom: (1.1.10 upstream) (4.1.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20090531183856-3xhvf6wd0bw5556i
Tags: 0.7.59-1
* New upstream release, first in Debian for the 0.7 branch. Among other
  issues, it also fixes the problem with wildcard dns names used with SSL.
  (Closes: #515904)
* debian/watch: updated.
* debian/postinst: fixed a bashism. (Closes: #507913)
* debian/conf/nginx.conf: removed default_type. (Closes: #509390)
* debian/control: updated Standards-Version to 3.8.1, no changes needed.
* debian/NEWS.Debian: documented the issues with
  server_names_hash_bucket_size. (Closes: #524785)

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
static ngx_http_output_header_filter_pt  ngx_http_next_header_filter;
48
48
 
49
49
 
50
 
static
51
 
ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r)
 
50
static ngx_int_t
 
51
ngx_http_not_modified_header_filter(ngx_http_request_t *r)
52
52
{
53
 
    time_t  ims;
 
53
    time_t                     ims;
 
54
    ngx_http_core_loc_conf_t  *clcf;
54
55
 
55
56
    if (r->headers_out.status != NGX_HTTP_OK
56
57
        || r != r->main
60
61
        return ngx_http_next_header_filter(r);
61
62
    }
62
63
 
 
64
    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
65
 
 
66
    if (clcf->if_modified_since == NGX_HTTP_IMS_OFF) {
 
67
        return ngx_http_next_header_filter(r);
 
68
    }
 
69
 
63
70
    ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data,
64
71
                              r->headers_in.if_modified_since->value.len);
65
72
 
66
73
    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
67
74
                   "http ims:%d lm:%d", ims, r->headers_out.last_modified_time);
68
75
 
69
 
    /*
70
 
     * I think that the equality of the dates is correcter
71
 
     */
 
76
    if (ims != r->headers_out.last_modified_time) {
72
77
 
73
 
    if (ims == r->headers_out.last_modified_time) {
74
 
        r->headers_out.status = NGX_HTTP_NOT_MODIFIED;
75
 
        r->headers_out.content_type.len = 0;
76
 
        ngx_http_clear_content_length(r);
77
 
        ngx_http_clear_accept_ranges(r);
 
78
        if (clcf->if_modified_since == NGX_HTTP_IMS_EXACT
 
79
            || ims < r->headers_out.last_modified_time)
 
80
        {
 
81
            return ngx_http_next_header_filter(r);
 
82
        }
78
83
    }
79
84
 
 
85
    r->headers_out.status = NGX_HTTP_NOT_MODIFIED;
 
86
    r->headers_out.status_line.len = 0;
 
87
    r->headers_out.content_type.len = 0;
 
88
    ngx_http_clear_content_length(r);
 
89
    ngx_http_clear_accept_ranges(r);
 
90
 
80
91
    return ngx_http_next_header_filter(r);
81
92
}
82
93
 
83
94
 
84
 
static
85
 
ngx_int_t ngx_http_not_modified_filter_init(ngx_conf_t *cf)
 
95
static ngx_int_t
 
96
ngx_http_not_modified_filter_init(ngx_conf_t *cf)
86
97
{
87
98
    ngx_http_next_header_filter = ngx_http_top_header_filter;
88
99
    ngx_http_top_header_filter = ngx_http_not_modified_header_filter;