Mercurial > hg > nginx
comparison src/http/ngx_http_header_filter.c @ 101:2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 04 Jun 2003 17:28:33 +0000 |
parents | 7ebc8b7fb816 |
children | 152567c11325 |
comparison
equal
deleted
inserted
replaced
100:7ebc8b7fb816 | 101:2e069b6e6920 |
---|---|
1 | 1 |
2 #include <ngx_config.h> | 2 #include <ngx_config.h> |
3 #include <ngx_core.h> | 3 #include <ngx_core.h> |
4 #include <ngx_http.h> | 4 #include <ngx_http.h> |
5 #include <nginx.h> | 5 #include <nginx.h> |
6 | |
7 /* STUB probably, needed for ngx_freebsd_tcp_nopush_flush */ | |
8 #ifdef __FreeBSD__ | |
9 #include <ngx_freebsd_init.h> | |
10 #endif | |
11 | |
6 | 12 |
7 | 13 |
8 static int ngx_http_header_filter_init(ngx_pool_t *pool); | 14 static int ngx_http_header_filter_init(ngx_pool_t *pool); |
9 static int ngx_http_header_filter(ngx_http_request_t *r); | 15 static int ngx_http_header_filter(ngx_http_request_t *r); |
10 | 16 |
92 time_t ims; | 98 time_t ims; |
93 ngx_hunk_t *h; | 99 ngx_hunk_t *h; |
94 ngx_chain_t *ch; | 100 ngx_chain_t *ch; |
95 ngx_table_elt_t *header; | 101 ngx_table_elt_t *header; |
96 | 102 |
103 #ifdef __FreeBSD__ | |
104 | |
105 if (r->keepalive) { | |
106 if (ngx_freebsd_tcp_nopush_flush) { | |
107 r->connection->tcp_nopush_enabled = 1; | |
108 } | |
109 | |
110 } else { | |
111 r->connection->tcp_nopush_enabled = 1; | |
112 } | |
113 | |
114 #else | |
115 | |
116 r->connection->tcp_nopush_enabled = 1; | |
117 | |
118 #endif | |
119 | |
97 if (r->http_version < NGX_HTTP_VERSION_10) { | 120 if (r->http_version < NGX_HTTP_VERSION_10) { |
98 return NGX_OK; | 121 return NGX_OK; |
99 } | 122 } |
100 | 123 |
101 if (r->method == NGX_HTTP_HEAD) { | 124 if (r->method == NGX_HTTP_HEAD) { |
217 if (r->chunked) { | 240 if (r->chunked) { |
218 /* "Transfer-Encoding: chunked\r\n" */ | 241 /* "Transfer-Encoding: chunked\r\n" */ |
219 len += 28; | 242 len += 28; |
220 } | 243 } |
221 | 244 |
222 if (r->keepalive == 0) { | 245 if (r->keepalive) { |
246 /* "Connection: keep-alive\r\n" */ | |
247 len += 24; | |
248 } else { | |
223 /* "Connection: close\r\n" */ | 249 /* "Connection: close\r\n" */ |
224 len += 19; | 250 len += 19; |
225 } else { | |
226 /* "Connection: keep-alive\r\n" */ | |
227 len += 24; | |
228 } | 251 } |
229 | 252 |
230 header = (ngx_table_elt_t *) r->headers_out.headers->elts; | 253 header = (ngx_table_elt_t *) r->headers_out.headers->elts; |
231 for (i = 0; i < r->headers_out.headers->nelts; i++) { | 254 for (i = 0; i < r->headers_out.headers->nelts; i++) { |
232 if (header[i].key.len == 0) { | 255 if (header[i].key.len == 0) { |
321 | 344 |
322 if (r->chunked) { | 345 if (r->chunked) { |
323 h->last = ngx_cpymem(h->last, "Transfer-Encoding: chunked" CRLF, 28); | 346 h->last = ngx_cpymem(h->last, "Transfer-Encoding: chunked" CRLF, 28); |
324 } | 347 } |
325 | 348 |
326 if (r->keepalive == 0) { | 349 if (r->keepalive) { |
350 h->last = ngx_cpymem(h->last, "Connection: keep-alive" CRLF, 24); | |
351 | |
352 } else { | |
327 h->last = ngx_cpymem(h->last, "Connection: close" CRLF, 19); | 353 h->last = ngx_cpymem(h->last, "Connection: close" CRLF, 19); |
328 | |
329 } else { | |
330 h->last = ngx_cpymem(h->last, "Connection: keep-alive" CRLF, 24); | |
331 } | 354 } |
332 | 355 |
333 for (i = 0; i < r->headers_out.headers->nelts; i++) { | 356 for (i = 0; i < r->headers_out.headers->nelts; i++) { |
334 if (header[i].key.len == 0) { | 357 if (header[i].key.len == 0) { |
335 continue; | 358 continue; |