comparison src/http/modules/ngx_http_headers_filter_module.c @ 86:962c43960644 NGINX_0_1_43

nginx 0.1.43 *) Feature: the listen(2) backlog in the "listen" directive can be changed using the -HUP signal. *) Feature: the geo2nginx.pl script was added to contrib. *) Change: the FastCGI parameters with the empty values now are passed to a server. *) Bugfix: the segmentation fault occurred or the worker process may got caught in an endless loop if the proxied or FastCGI server sent the "Cache-Control" header line and the "expires" directive was used; in the proxied mode the bug appeared in 0.1.29.
author Igor Sysoev <http://sysoev.ru>
date Tue, 30 Aug 2005 00:00:00 +0400
parents b55cbf18157e
children 71c46860eb55
comparison
equal deleted inserted replaced
85:ed21d13ec23c 86:962c43960644
71 static ngx_int_t 71 static ngx_int_t
72 ngx_http_headers_filter(ngx_http_request_t *r) 72 ngx_http_headers_filter(ngx_http_request_t *r)
73 { 73 {
74 size_t len; 74 size_t len;
75 ngx_uint_t i; 75 ngx_uint_t i;
76 ngx_table_elt_t *expires, *cc; 76 ngx_table_elt_t *expires, *cc, **ccp;
77 ngx_http_headers_conf_t *conf; 77 ngx_http_headers_conf_t *conf;
78 78
79 if (r->headers_out.status != NGX_HTTP_OK || r->main) { 79 if (r->headers_out.status != NGX_HTTP_OK || r->main) {
80 return ngx_http_next_header_filter(r); 80 return ngx_http_next_header_filter(r);
81 } 81 }
101 } 101 }
102 102
103 len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT"); 103 len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT");
104 expires->value.len = len - 1; 104 expires->value.len = len - 1;
105 105
106 cc = r->headers_out.cache_control.elts; 106 ccp = r->headers_out.cache_control.elts;
107 107
108 if (cc == NULL) { 108 if (ccp == NULL) {
109
110 if (ngx_array_init(&r->headers_out.cache_control, r->pool,
111 1, sizeof(ngx_table_elt_t *)) != NGX_OK)
112 {
113 return NGX_ERROR;
114 }
115
116 ccp = ngx_array_push(&r->headers_out.cache_control);
117 if (ccp == NULL) {
118 return NGX_ERROR;
119 }
109 120
110 cc = ngx_list_push(&r->headers_out.headers); 121 cc = ngx_list_push(&r->headers_out.headers);
111 if (cc == NULL) { 122 if (cc == NULL) {
112 return NGX_ERROR; 123 return NGX_ERROR;
113 } 124 }
114 125
115 cc->hash = 1; 126 cc->hash = 1;
116 cc->key.len = sizeof("Cache-Control") - 1; 127 cc->key.len = sizeof("Cache-Control") - 1;
117 cc->key.data = (u_char *) "Cache-Control"; 128 cc->key.data = (u_char *) "Cache-Control";
118 129
130 *ccp = cc;
131
119 } else { 132 } else {
120 for (i = 1; i < r->headers_out.cache_control.nelts; i++) { 133 for (i = 1; i < r->headers_out.cache_control.nelts; i++) {
121 cc[i].hash = 0; 134 ccp[i]->hash = 0;
122 } 135 }
136
137 cc = ccp[0];
123 } 138 }
124 139
125 if (conf->expires == NGX_HTTP_EXPIRES_EPOCH) { 140 if (conf->expires == NGX_HTTP_EXPIRES_EPOCH) {
126 expires->value.data = (u_char *) "Thu, 01 Jan 1970 00:00:01 GMT"; 141 expires->value.data = (u_char *) "Thu, 01 Jan 1970 00:00:01 GMT";
127 142