Mercurial > hg > nginx
comparison src/http/ngx_http_header_filter_module.c @ 1725:0a174d921f1e stable-0.5
r1593, r1595 merge:
server_tokens
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 12 Dec 2007 20:53:06 +0000 |
parents | bbde03037ef6 |
children |
comparison
equal
deleted
inserted
replaced
1724:461d00e8a2a9 | 1725:0a174d921f1e |
---|---|
43 NULL, /* exit master */ | 43 NULL, /* exit master */ |
44 NGX_MODULE_V1_PADDING | 44 NGX_MODULE_V1_PADDING |
45 }; | 45 }; |
46 | 46 |
47 | 47 |
48 static char ngx_http_server_string[] = "Server: " NGINX_VER CRLF; | 48 static char ngx_http_server_string[] = "Server: nginx" CRLF; |
49 static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF; | |
49 | 50 |
50 | 51 |
51 static ngx_str_t ngx_http_status_lines[] = { | 52 static ngx_str_t ngx_http_status_lines[] = { |
52 | 53 |
53 ngx_string("200 OK"), | 54 ngx_string("200 OK"), |
235 } | 236 } |
236 | 237 |
237 len += ngx_http_status_lines[status].len; | 238 len += ngx_http_status_lines[status].len; |
238 } | 239 } |
239 | 240 |
241 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
242 | |
240 if (r->headers_out.server == NULL) { | 243 if (r->headers_out.server == NULL) { |
241 len += sizeof(ngx_http_server_string) - 1; | 244 len += clcf->server_tokens ? sizeof(ngx_http_server_full_string) - 1: |
245 sizeof(ngx_http_server_string) - 1; | |
242 } | 246 } |
243 | 247 |
244 if (r->headers_out.date == NULL) { | 248 if (r->headers_out.date == NULL) { |
245 len += sizeof("Date: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; | 249 len += sizeof("Date: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; |
246 } | 250 } |
265 if (r->headers_out.last_modified == NULL | 269 if (r->headers_out.last_modified == NULL |
266 && r->headers_out.last_modified_time != -1) | 270 && r->headers_out.last_modified_time != -1) |
267 { | 271 { |
268 len += sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; | 272 len += sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; |
269 } | 273 } |
270 | |
271 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
272 | 274 |
273 if (r->headers_out.location | 275 if (r->headers_out.location |
274 && r->headers_out.location->value.len | 276 && r->headers_out.location->value.len |
275 && r->headers_out.location->value.data[0] == '/') | 277 && r->headers_out.location->value.data[0] == '/') |
276 { | 278 { |
363 ngx_http_status_lines[status].len); | 365 ngx_http_status_lines[status].len); |
364 } | 366 } |
365 *b->last++ = CR; *b->last++ = LF; | 367 *b->last++ = CR; *b->last++ = LF; |
366 | 368 |
367 if (r->headers_out.server == NULL) { | 369 if (r->headers_out.server == NULL) { |
368 b->last = ngx_cpymem(b->last, ngx_http_server_string, | 370 if (clcf->server_tokens) { |
369 sizeof(ngx_http_server_string) - 1); | 371 p = (u_char *) ngx_http_server_full_string; |
372 len = sizeof(ngx_http_server_full_string) - 1; | |
373 | |
374 } else { | |
375 p = (u_char *) ngx_http_server_string; | |
376 len = sizeof(ngx_http_server_string) - 1; | |
377 } | |
378 | |
379 b->last = ngx_cpymem(b->last, p, len); | |
370 } | 380 } |
371 | 381 |
372 if (r->headers_out.date == NULL) { | 382 if (r->headers_out.date == NULL) { |
373 b->last = ngx_cpymem(b->last, "Date: ", sizeof("Date: ") - 1); | 383 b->last = ngx_cpymem(b->last, "Date: ", sizeof("Date: ") - 1); |
374 b->last = ngx_cpymem(b->last, ngx_cached_http_time.data, | 384 b->last = ngx_cpymem(b->last, ngx_cached_http_time.data, |