Mercurial > hg > nginx
comparison src/http/ngx_http_header_filter.c @ 429:694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 17 Sep 2004 16:07:35 +0000 |
parents | fda5987b188d |
children | 11362a3e3911 |
comparison
equal
deleted
inserted
replaced
428:5e73d0ea4dab | 429:694cd6cdb714 |
---|---|
112 }; | 112 }; |
113 | 113 |
114 | 114 |
115 static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r) | 115 static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r) |
116 { | 116 { |
117 u_char *p; | 117 u_char *p; |
118 size_t len; | 118 size_t len; |
119 ngx_uint_t status, i; | 119 ngx_uint_t status, i; |
120 ngx_buf_t *b; | 120 ngx_buf_t *b; |
121 ngx_chain_t *ln; | 121 ngx_chain_t *ln; |
122 ngx_list_part_t *part; | 122 ngx_list_part_t *part; |
123 ngx_table_elt_t *header; | 123 ngx_table_elt_t *header; |
124 ngx_http_core_loc_conf_t *clcf; | |
124 | 125 |
125 if (r->http_version < NGX_HTTP_VERSION_10) { | 126 if (r->http_version < NGX_HTTP_VERSION_10) { |
126 return NGX_OK; | 127 return NGX_OK; |
127 } | 128 } |
128 | 129 |
220 | 221 |
221 if (r->chunked) { | 222 if (r->chunked) { |
222 len += sizeof("Transfer-Encoding: chunked" CRLF) - 1; | 223 len += sizeof("Transfer-Encoding: chunked" CRLF) - 1; |
223 } | 224 } |
224 | 225 |
226 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
227 | |
225 if (r->keepalive) { | 228 if (r->keepalive) { |
226 len += sizeof("Connection: keep-alive" CRLF) - 1; | 229 len += sizeof("Connection: keep-alive" CRLF) - 1; |
230 | |
231 /* | |
232 * MSIE and Opera ignore the "Keep-Alive: timeout=<N>" header. | |
233 * MSIE keeps the connection alive for about 60-65 seconds. | |
234 * Opera keeps the connection alive very long. | |
235 * Mozilla keeps the connection alive for N plus about 1-10 seconds. | |
236 * Konqueror keeps the connection alive for about N seconds. | |
237 */ | |
238 | |
239 if (clcf->keepalive_header | |
240 && (r->headers_in.gecko || r->headers_in.konqueror)) | |
241 { | |
242 len += sizeof("Keep-Alive: timeout=") - 1 + TIME_T_LEN + 2; | |
243 } | |
244 | |
227 } else { | 245 } else { |
228 len += sizeof("Connection: closed" CRLF) - 1; | 246 len += sizeof("Connection: closed" CRLF) - 1; |
229 } | 247 } |
230 | 248 |
231 part = &r->headers_out.headers.part; | 249 part = &r->headers_out.headers.part; |
240 | 258 |
241 part = part->next; | 259 part = part->next; |
242 header = part->elts; | 260 header = part->elts; |
243 i = 0; | 261 i = 0; |
244 } | 262 } |
245 | |
246 #if 0 | |
247 header = r->headers_out.headers.elts; | |
248 for (i = 0; i < r->headers_out.headers.nelts; i++) { | |
249 #endif | |
250 | 263 |
251 if (header[i].key.len == 0) { | 264 if (header[i].key.len == 0) { |
252 continue; | 265 continue; |
253 } | 266 } |
254 | 267 |
355 | 368 |
356 if (r->keepalive) { | 369 if (r->keepalive) { |
357 b->last = ngx_cpymem(b->last, "Connection: keep-alive" CRLF, | 370 b->last = ngx_cpymem(b->last, "Connection: keep-alive" CRLF, |
358 sizeof("Connection: keep-alive" CRLF) - 1); | 371 sizeof("Connection: keep-alive" CRLF) - 1); |
359 | 372 |
373 if (clcf->keepalive_header | |
374 && (r->headers_in.gecko || r->headers_in.konqueror)) | |
375 { | |
376 b->last += ngx_snprintf((char *) b->last, | |
377 sizeof("Keep-Alive: timeout=") + TIME_T_LEN + 2, | |
378 "Keep-Alive: timeout=" TIME_T_FMT CRLF, | |
379 clcf->keepalive_header); | |
380 } | |
381 | |
360 } else { | 382 } else { |
361 b->last = ngx_cpymem(b->last, "Connection: close" CRLF, | 383 b->last = ngx_cpymem(b->last, "Connection: close" CRLF, |
362 sizeof("Connection: close" CRLF) - 1); | 384 sizeof("Connection: close" CRLF) - 1); |
363 } | 385 } |
364 | 386 |
375 part = part->next; | 397 part = part->next; |
376 header = part->elts; | 398 header = part->elts; |
377 i = 0; | 399 i = 0; |
378 } | 400 } |
379 | 401 |
380 #if 0 | |
381 for (i = 0; i < r->headers_out.headers.nelts; i++) { | |
382 #endif | |
383 | |
384 if (header[i].key.len == 0) { | 402 if (header[i].key.len == 0) { |
385 continue; | 403 continue; |
386 } | 404 } |
387 | 405 |
388 b->last = ngx_cpymem(b->last, header[i].key.data, header[i].key.len); | 406 b->last = ngx_cpymem(b->last, header[i].key.data, header[i].key.len); |