Mercurial > hg > nginx-mail
comparison src/http/ngx_http_header_filter_module.c @ 665:0b460e61bdcd default tip
Merge with nginx 1.0.0.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 25 Apr 2011 04:22:17 +0400 |
parents | c456a023113c |
children |
comparison
equal
deleted
inserted
replaced
572:06419a2298a9 | 665:0b460e61bdcd |
---|---|
51 | 51 |
52 static ngx_str_t ngx_http_status_lines[] = { | 52 static ngx_str_t ngx_http_status_lines[] = { |
53 | 53 |
54 ngx_string("200 OK"), | 54 ngx_string("200 OK"), |
55 ngx_string("201 Created"), | 55 ngx_string("201 Created"), |
56 ngx_null_string, /* "202 Accepted" */ | 56 ngx_string("202 Accepted"), |
57 ngx_null_string, /* "203 Non-Authoritative Information" */ | 57 ngx_null_string, /* "203 Non-Authoritative Information" */ |
58 ngx_string("204 No Content"), | 58 ngx_string("204 No Content"), |
59 ngx_null_string, /* "205 Reset Content" */ | 59 ngx_null_string, /* "205 Reset Content" */ |
60 ngx_string("206 Partial Content"), | 60 ngx_string("206 Partial Content"), |
61 | 61 |
66 | 66 |
67 /* ngx_null_string, */ /* "300 Multiple Choices" */ | 67 /* ngx_null_string, */ /* "300 Multiple Choices" */ |
68 | 68 |
69 ngx_string("301 Moved Permanently"), | 69 ngx_string("301 Moved Permanently"), |
70 ngx_string("302 Moved Temporarily"), | 70 ngx_string("302 Moved Temporarily"), |
71 ngx_null_string, /* "303 See Other" */ | 71 ngx_string("303 See Other"), |
72 ngx_string("304 Not Modified"), | 72 ngx_string("304 Not Modified"), |
73 | 73 |
74 /* ngx_null_string, */ /* "305 Use Proxy" */ | 74 /* ngx_null_string, */ /* "305 Use Proxy" */ |
75 /* ngx_null_string, */ /* "306 unused" */ | 75 /* ngx_null_string, */ /* "306 unused" */ |
76 /* ngx_null_string, */ /* "307 Temporary Redirect" */ | 76 /* ngx_null_string, */ /* "307 Temporary Redirect" */ |
130 | 130 |
131 | 131 |
132 ngx_http_header_out_t ngx_http_headers_out[] = { | 132 ngx_http_header_out_t ngx_http_headers_out[] = { |
133 { ngx_string("Server"), offsetof(ngx_http_headers_out_t, server) }, | 133 { ngx_string("Server"), offsetof(ngx_http_headers_out_t, server) }, |
134 { ngx_string("Date"), offsetof(ngx_http_headers_out_t, date) }, | 134 { ngx_string("Date"), offsetof(ngx_http_headers_out_t, date) }, |
135 #if 0 | |
136 { ngx_string("Content-Type"), | |
137 offsetof(ngx_http_headers_out_t, content_type) }, | |
138 #endif | |
139 { ngx_string("Content-Length"), | 135 { ngx_string("Content-Length"), |
140 offsetof(ngx_http_headers_out_t, content_length) }, | 136 offsetof(ngx_http_headers_out_t, content_length) }, |
141 { ngx_string("Content-Encoding"), | 137 { ngx_string("Content-Encoding"), |
142 offsetof(ngx_http_headers_out_t, content_encoding) }, | 138 offsetof(ngx_http_headers_out_t, content_encoding) }, |
143 { ngx_string("Location"), offsetof(ngx_http_headers_out_t, location) }, | 139 { ngx_string("Location"), offsetof(ngx_http_headers_out_t, location) }, |
172 #if (NGX_HAVE_INET6) | 168 #if (NGX_HAVE_INET6) |
173 struct sockaddr_in6 *sin6; | 169 struct sockaddr_in6 *sin6; |
174 #endif | 170 #endif |
175 u_char addr[NGX_SOCKADDR_STRLEN]; | 171 u_char addr[NGX_SOCKADDR_STRLEN]; |
176 | 172 |
173 if (r->header_sent) { | |
174 return NGX_OK; | |
175 } | |
176 | |
177 r->header_sent = 1; | 177 r->header_sent = 1; |
178 | 178 |
179 if (r != r->main) { | 179 if (r != r->main) { |
180 return NGX_OK; | 180 return NGX_OK; |
181 } | 181 } |
220 { | 220 { |
221 /* 2XX */ | 221 /* 2XX */ |
222 | 222 |
223 if (status == NGX_HTTP_NO_CONTENT) { | 223 if (status == NGX_HTTP_NO_CONTENT) { |
224 r->header_only = 1; | 224 r->header_only = 1; |
225 r->headers_out.content_type.len = 0; | 225 ngx_str_null(&r->headers_out.content_type); |
226 r->headers_out.content_type.data = NULL; | |
227 r->headers_out.last_modified_time = -1; | 226 r->headers_out.last_modified_time = -1; |
228 r->headers_out.last_modified = NULL; | 227 r->headers_out.last_modified = NULL; |
229 r->headers_out.content_length = NULL; | 228 r->headers_out.content_length = NULL; |
230 r->headers_out.content_length_n = -1; | 229 r->headers_out.content_length_n = -1; |
231 } | 230 } |
340 case AF_INET6: | 339 case AF_INET6: |
341 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; | 340 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
342 port = ntohs(sin6->sin6_port); | 341 port = ntohs(sin6->sin6_port); |
343 break; | 342 break; |
344 #endif | 343 #endif |
344 #if (NGX_HAVE_UNIX_DOMAIN) | |
345 case AF_UNIX: | |
346 port = 0; | |
347 break; | |
348 #endif | |
345 default: /* AF_INET */ | 349 default: /* AF_INET */ |
346 sin = (struct sockaddr_in *) c->local_sockaddr; | 350 sin = (struct sockaddr_in *) c->local_sockaddr; |
347 port = ntohs(sin->sin_port); | 351 port = ntohs(sin->sin_port); |
348 break; | 352 break; |
349 } | 353 } |
368 if (port) { | 372 if (port) { |
369 len += sizeof(":65535") - 1; | 373 len += sizeof(":65535") - 1; |
370 } | 374 } |
371 | 375 |
372 } else { | 376 } else { |
373 host.len = 0; | 377 ngx_str_null(&host); |
374 host.data = NULL; | |
375 port = 0; | 378 port = 0; |
376 } | 379 } |
377 | 380 |
378 if (r->chunked) { | 381 if (r->chunked) { |
379 len += sizeof("Transfer-Encoding: chunked" CRLF) - 1; | 382 len += sizeof("Transfer-Encoding: chunked" CRLF) - 1; |
397 } else { | 400 } else { |
398 len += sizeof("Connection: closed" CRLF) - 1; | 401 len += sizeof("Connection: closed" CRLF) - 1; |
399 } | 402 } |
400 | 403 |
401 #if (NGX_HTTP_GZIP) | 404 #if (NGX_HTTP_GZIP) |
402 if (r->gzip && clcf->gzip_vary) { | 405 if (r->gzip_vary) { |
403 len += sizeof("Vary: Accept-Encoding" CRLF) - 1; | 406 if (clcf->gzip_vary) { |
407 len += sizeof("Vary: Accept-Encoding" CRLF) - 1; | |
408 | |
409 } else { | |
410 r->gzip_vary = 0; | |
411 } | |
404 } | 412 } |
405 #endif | 413 #endif |
406 | 414 |
407 part = &r->headers_out.headers.part; | 415 part = &r->headers_out.headers.part; |
408 header = part->elts; | 416 header = part->elts; |
531 | 539 |
532 /* update r->headers_out.location->value for possible logging */ | 540 /* update r->headers_out.location->value for possible logging */ |
533 | 541 |
534 r->headers_out.location->value.len = b->last - p; | 542 r->headers_out.location->value.len = b->last - p; |
535 r->headers_out.location->value.data = p; | 543 r->headers_out.location->value.data = p; |
536 r->headers_out.location->key.len = sizeof("Location: ") - 1; | 544 ngx_str_set(&r->headers_out.location->key, "Location"); |
537 r->headers_out.location->key.data = (u_char *) "Location: "; | |
538 | 545 |
539 *b->last++ = CR; *b->last++ = LF; | 546 *b->last++ = CR; *b->last++ = LF; |
540 } | 547 } |
541 | 548 |
542 if (r->chunked) { | 549 if (r->chunked) { |
557 b->last = ngx_cpymem(b->last, "Connection: close" CRLF, | 564 b->last = ngx_cpymem(b->last, "Connection: close" CRLF, |
558 sizeof("Connection: close" CRLF) - 1); | 565 sizeof("Connection: close" CRLF) - 1); |
559 } | 566 } |
560 | 567 |
561 #if (NGX_HTTP_GZIP) | 568 #if (NGX_HTTP_GZIP) |
562 if (r->gzip && clcf->gzip_vary) { | 569 if (r->gzip_vary) { |
563 b->last = ngx_cpymem(b->last, "Vary: Accept-Encoding" CRLF, | 570 b->last = ngx_cpymem(b->last, "Vary: Accept-Encoding" CRLF, |
564 sizeof("Vary: Accept-Encoding" CRLF) - 1); | 571 sizeof("Vary: Accept-Encoding" CRLF) - 1); |
565 } | 572 } |
566 #endif | 573 #endif |
567 | 574 |