comparison src/http/ngx_http_header_filter.c @ 208:0b67be7d4489

nginx-0.0.1-2003-12-08-23:48:12 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 08 Dec 2003 20:48:12 +0000
parents 8dee38ea9117
children 00cafae0bdf1
comparison
equal deleted inserted replaced
207:6e0fef527732 208:0b67be7d4489
156 len += sizeof("Date: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; 156 len += sizeof("Date: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1;
157 } 157 }
158 158
159 if (r->headers_out.content_length == NULL) { 159 if (r->headers_out.content_length == NULL) {
160 if (r->headers_out.content_length_n >= 0) { 160 if (r->headers_out.content_length_n >= 0) {
161 /* 2^64 */ 161 len += sizeof("Content-Length: ") - 1 + NGX_OFF_T_LEN + 2;
162 len += sizeof("Content-Length: 18446744073709551616" CRLF) - 1;
163 } 162 }
164 } 163 }
165 164
166 if (r->headers_out.content_type && r->headers_out.content_type->value.len) { 165 if (r->headers_out.content_type && r->headers_out.content_type->value.len) {
167 r->headers_out.content_type->key.len = 0; 166 r->headers_out.content_type->key.len = 0;
236 h->last = ngx_cpymem(h->last, server_string, sizeof(server_string) - 1); 235 h->last = ngx_cpymem(h->last, server_string, sizeof(server_string) - 1);
237 } 236 }
238 237
239 if (!(r->headers_out.date && r->headers_out.date->key.len)) { 238 if (!(r->headers_out.date && r->headers_out.date->key.len)) {
240 h->last = ngx_cpymem(h->last, "Date: ", sizeof("Date: ") - 1); 239 h->last = ngx_cpymem(h->last, "Date: ", sizeof("Date: ") - 1);
241 #if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
242 p = h->last;
243 #endif
244 h->last = ngx_cpymem(h->last, ngx_cached_http_time.data, 240 h->last = ngx_cpymem(h->last, ngx_cached_http_time.data,
245 ngx_cached_http_time.len); 241 ngx_cached_http_time.len);
246 242
247 #if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
248 r->headers_out.date = ngx_palloc(r->pool, sizeof(ngx_table_elt_t));
249 if (r->headers_out.date == NULL) {
250 return NGX_ERROR;
251 }
252
253 r->headers_out.date->key.len = 0;
254 r->headers_out.date->key.data = NULL;
255 r->headers_out.date->value.len = h->last - p;
256 r->headers_out.date->value.data = p;
257 #endif
258
259 *(h->last++) = CR; *(h->last++) = LF; 243 *(h->last++) = CR; *(h->last++) = LF;
260 } 244 }
261 245
262 if (r->headers_out.content_length == NULL) { 246 if (r->headers_out.content_length == NULL) {
263 if (r->headers_out.content_length_n >= 0) { 247 if (r->headers_out.content_length_n >= 0) {
264 #if (NGX_HTTP_LOG_ALL_HEADERS_OUT) 248 h->last += ngx_snprintf(h->last,
265 p = h->last + sizeof("Content-Length: ") - 1; 249 sizeof("Content-Length: ") + NGX_OFF_T_LEN + 2,
266 #endif 250 "Content-Length: " OFF_T_FMT CRLF,
267 h->last += ngx_snprintf(h->last, /* 2^64 */ 251 r->headers_out.content_length_n);
268 sizeof("Content-Length: 18446744073709551616" CRLF),
269 "Content-Length: " OFF_T_FMT CRLF,
270 r->headers_out.content_length_n);
271
272 #if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
273 r->headers_out.content_length = ngx_palloc(r->pool,
274 sizeof(ngx_table_elt_t));
275 if (r->headers_out.content_length == NULL) {
276 return NGX_ERROR;
277 }
278
279 r->headers_out.content_length->key.len = 0;
280 r->headers_out.content_length->key.data = NULL;
281 r->headers_out.content_length->value.len = h->last - p - 2;
282 r->headers_out.content_length->value.data = p;
283 #endif
284 } 252 }
285 } 253 }
286 254
287 if (r->headers_out.content_type && r->headers_out.content_type->value.len) { 255 if (r->headers_out.content_type && r->headers_out.content_type->value.len) {
288 h->last = ngx_cpymem(h->last, "Content-Type: ", 256 h->last = ngx_cpymem(h->last, "Content-Type: ",
330 if (!(r->headers_out.last_modified && r->headers_out.last_modified->key.len) 298 if (!(r->headers_out.last_modified && r->headers_out.last_modified->key.len)
331 && r->headers_out.last_modified_time != -1) 299 && r->headers_out.last_modified_time != -1)
332 { 300 {
333 h->last = ngx_cpymem(h->last, "Last-Modified: ", 301 h->last = ngx_cpymem(h->last, "Last-Modified: ",
334 sizeof("Last-Modified: ") - 1); 302 sizeof("Last-Modified: ") - 1);
335 #if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
336 p = h->last;
337 #endif
338 h->last += ngx_http_time(h->last, r->headers_out.last_modified_time); 303 h->last += ngx_http_time(h->last, r->headers_out.last_modified_time);
339
340 #if (NGX_HTTP_LOG_ALL_HEADERS_OUT)
341 r->headers_out.last_modified = ngx_palloc(r->pool,
342 sizeof(ngx_table_elt_t));
343 if (r->headers_out.last_modified == NULL) {
344 return NGX_ERROR;
345 }
346
347 r->headers_out.last_modified->key.len = 0;
348 r->headers_out.last_modified->key.data = NULL;
349 r->headers_out.last_modified->value.len = h->last - p;
350 r->headers_out.last_modified->value.data = p;
351 #endif
352 304
353 *(h->last++) = CR; *(h->last++) = LF; 305 *(h->last++) = CR; *(h->last++) = LF;
354 } 306 }
355 307
356 if (r->chunked) { 308 if (r->chunked) {